Java Transaction - Couchbase 6.6 - single node local development

I am trying a local transaction but every time I get following warning

Can someone please help? I am using a scope and collection created on bucket.
I am not using default scope or collection

2021-04-13 23:42:20.306 WARN 11660 — [ cb-events] com.couchbase.config : [com.couchbase.config][CollectionMapRefreshFailedEvent][702us] Collection Map refresh (CollectionIdentifier{bucket=‘myBucket’, scope=Optional[myScope], collection=Optional[myCollection], isDefault=false}) failed: INVALID_REQUEST {“coreId”:“0xf4e52b4400000001”}
2021-04-13 23:42:20.306 WARN 11660 — [ cb-events] com.couchbase.endpoint : [com.couchbase.endpoint][UnexpectedEndpointDisconnectedEvent] The remote side disconnected the endpoint unexpectedly {“bucket”:“myBucket”,“channelId”:“F4E52B4400000001/00000000C33756E5”,“circuitBreaker”:“DISABLED”,“coreId”:“0xf4e52b4400000001”,“local”:“127.0.0.1:51023”,“remote”:“127.0.0.1:11210”,“type”:“KV”}

I am using following statemenet to get collection:
ReactiveCollection collectionRef = clientFactory.getBucket().scope(“myScope”).reactive().collection(“myCollection”);

When I run cbstats on my bucket I can see it’s writing to _default collection, but I can’t query because it’s writing in binary type.

Not sure why it’s writing when I already have above two warnings and when I am requesting a specific collection ( myCollection )

Hi Satya,

What version of the Java SDK are you using?

There have been some changes to the collections protocol between the developer preview of collections in Couchbase Server 6.6 and the version being finalized for Couchbase 7.0 (available now in beta).

Java SDK versions 3.1.4 and later are only compatible with the new protocol in 7.0. See
JVMCBC-941 and the related issues if you’re curious about the details.

Thanks,
David

Thanks David
When I changed version to Java SDK versions 3.1.3 it worked.

One more question if you can help
Why the transaction is saving documents in Binary Document format?

Let’s continue the discussion in the other thread: Object stored as binary insteed of json

Sure, David we can continue on another thread

Hi David
I have upgraded the couchbase to 7 beta and using

couchbase-transactions - 1.1.6
java-client - 3.1.4
spring-data-couchbase - 4.2.0

I am getting following error again

2021-04-20 23:51:58.358 WARN 31720 — [ cb-events] com.couchbase.config : [com.couchbase.config][CollectionMapRefreshFailedEvent][731us] Collection Map refresh (CollectionIdentifier{bucket=‘myBucket’, scope=Optional[myScope], collection=Optional[myCollection], isDefault=false}) failed: INVALID_REQUEST {“coreId”:“0xc2aa1bb900000001”}

can you please help?

Hi Satya,

My guess is you’ll need to downgrade to 3.1.3, or wait for a newer version of the 7 beta.

Thanks,
David

@satyanandkumbhar
Yes, David is correct, java-client 3.1.4 is not compatible with the beta version of 7.0 in certain specific ways, it is intended for the upcoming (soon!) 7.0 GA release. Anything you can do with previous releases of Couchbase will work fine, but for anything involving non-default collections, you will see that error you are seeing. Please continue with the 3.1.3 SDK release with the 7.0 beta if you are using non-default collections.

Thanks David and Graham

java-client 3.1.3 worked.

I have a new query I am looking to insert into two collections in one transaction. But when I try only one get’s inserted. I am using reactive api’s

e.g.

ctx.insert(
reactiveCollectionOne,
newId,
employee);

ctx.insert(
reactiveCollectionTwo,
newId2,
address).then(ctx.commit());

Hi @satyanandkumbhar
With reactive programming you generally need to chain your reactive operators together, e.g. using concatMap or flatMap. Take a look at the async API example on Distributed Transactions from the Java SDK | Couchbase Docs.
Reactive programming can be tricky if you’re unfamiliar with it, and is intended mainly for users that want to parallelise the transaction staging to absolutely minimise latency. If that isn’t such a requirement for you then you might prefer to use the blocking API, which is much more straightforward to use.

Here’s an example:

       transactions.reactive().run(ctx -> {
            return ctx.insert(reactiveCollectionOne, newId, employee)
                    .then(ctx.insert(reactiveCollectionTwo, newId2, address));
        });

I’ve used .then() rather than flatMap, as the second insert doesn’t care about the result of the first. And I’ve left off the ctx.commit(), which is optional.