Skip to content

Instantly share code, notes, and snippets.

@scottmarlow
Last active June 8, 2016 14:38
Show Gist options
  • Save scottmarlow/6895f15219ca16a5bc95fc19ef5b397e to your computer and use it in GitHub Desktop.
Save scottmarlow/6895f15219ca16a5bc95fc19ef5b397e to your computer and use it in GitHub Desktop.
MongoDB subsystem configuration with write-concern override, pick one
The MongoDB configuration includes specifying an optional override of the database servers write-concern setting.
The write-concern setting may reference the predefined constants (e.g. https://api.mongodb.com/java/3.1/com/mongodb/WriteConcern.html#ACKNOWLEDGED) or a custom set of values (see https://api.mongodb.com/java/3.1/com/mongodb/WriteConcern.html#WriteConcern-int-int-boolean-boolean-).
Example with custom write-concern called "custom-write-concern":
<subsystem xmlns="urn:jboss:domain:mongodb:1.0">
<mongo name="default1" id="mongodbtestprofile_ack" jndi-name="java:jboss/mongodb/test_ack" database="mongotestdb" write-concern="ACKNOWLEDGED">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
</mongo>
<mongo name="default2" id="mongodbtestprofile_unack" jndi-name="java:jboss/mongodb/test_unack" database="mongotestdb" write-concern="UNACKNOWLEDGED">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
</mongo>
<mongo name="default3" id="mongodbtestprofile_custom" jndi-name="java:jboss/mongodb/test_custom" database="mongotestdb">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
<custom-write-concern name="default” w=“1” j=“true” wtimeout=“1”/>
</mongo>
</subsystem>
Example with custom write-concern called "write-concern":
<subsystem xmlns="urn:jboss:domain:mongodb:1.0">
<mongo name="default1" id="mongodbtestprofile_ack" jndi-name="java:jboss/mongodb/test_ack" database="mongotestdb" write-concern="ACKNOWLEDGED">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
</mongo>
<mongo name="default2" id="mongodbtestprofile_unack" jndi-name="java:jboss/mongodb/test_unack" database="mongotestdb" write-concern="UNACKNOWLEDGED">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
</mongo>
<mongo name="default3" id="mongodbtestprofile_custom" jndi-name="java:jboss/mongodb/test_custom" database="mongotestdb">
<host name="default" outbound-socket-binding-ref="mongotesthost"/>
<write-concern name="default” w=“1” j=“true” wtimeout=“1”/>
</mongo>
</subsystem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment