[JAVA-1316] Multiple Mongo Instances always have the same MongoOption Reference Created: 21/Jul/14  Updated: 11/Sep/19  Resolved: 21/Jul/14

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 2.10.1
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Sulbigar Shanawaz Assignee: Unassigned
Resolution: Done Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Software


Backwards Compatibility: Fully Compatible

 Description   

Team,

I'm trying to create two instance of Mongo with different MongoOptions as the need is to connect to two different database within the same mongo host but with different connection parameters.

But only one instance of MongoOption is created and only one of the possible connection parameters are set as the other one gets overridden during the second Mongo instance initialization.

Is there a way to create two different instances of MongoOptions?

The configuration is given below.
<mongo:mongo replica-set="${mongo.host}" id="apiMongo">
<mongo:options connections-per-host="8"
threads-allowed-to-block-for-connection-multiplier="2"
connect-timeout="12000"
max-wait-time="12000"
auto-connect-retry="true"
socket-keep-alive="true"
socket-timeout="120000"
/>
</mongo:mongo>

<mongo:mongo replica-set="${mongo.host}" id="systemMongo">
<mongo:options connections-per-host="8"
threads-allowed-to-block-for-connection-multiplier="2"
connect-timeout="2000"
max-wait-time="2000"
auto-connect-retry="true"
socket-keep-alive="true"
socket-timeout="2000"
/>
</mongo:mongo>

Two instances of Mongo is created and they both point to a single instance of MongoOptions. Is there a way to create multiple instances of MongoOption?



 Comments   
Comment by Sulbigar Shanawaz [ 21/Jul/14 ]

Sure. Thank You.

Comment by Jeffrey Yemin [ 21/Jul/14 ]

No problem. I'll close this ticket then, but please post again if there's anything else we can help with.

Comment by Sulbigar Shanawaz [ 21/Jul/14 ]

Apologies,
I just figured that out. I'm drafting a query there as well. But doing bit more research before I post there.

Thank You for the assistance

Comment by Jeffrey Yemin [ 21/Jul/14 ]

This seems like more of a Spring question than a driver question to me. Are you using Spring Data MongoDB? Have you posted this question to https://jira.spring.io/browse/DATAMONGO?

Generated at Thu Feb 08 08:54:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.