| Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components | |
| Close Print View | |
| Designing: Enabling Rollback When an MSMQ Message Fails |
|
Creating a Runtime Environment
Designing Business Processes in the Sun Business Process Manager
Working with TCP/IP HL7 Collaborations
Developing Sun Master Indexes (Repository)
Developing Sun Master Patient Indexes
Developing OTDs for Application Adapters
Developing OTDs for Communication Adapters
Developing OTDs for Database Adapters
Developing OTDs for Web Server Adapters
Designing with Application Adapters
Designing with Communication Adapters
Adding the DLL file to the Path for the COM/DCOM Application Server Process
To Add the DLL file to the Path for the Application Server Process
Installing the MSMQ DLL and JNI Files
To Download the MSMQ DLLs and Runtime JNI
To Add the DLL Files to the Environment Path
Streaming Data Between Components with the Batch Adapter
Introduction to Data Streaming
Overcoming Large-file Limitations
Designing with Web Server Adapters
Designing with Sun JCA Adapters
In order to roll back an outbound MSMQ message when a failure occurs in the Java Collaboration Definition (for example, failure to insert a duplicate row into a database table that is defined to have unique keys), do the following:
try {
MSMQClient_1.getEwayConfiguration().setOutMSMQName( "public" );
MSMQClient_1.getEwayConfiguration().setOutMSMQShareMode( "DENY_RECEIVE_SHARE" );
MSMQClient_1.getEwayConfiguration().setOutMSMQReceiveActionCode ( "ACTION_PEEK_CURRENT" );
MSMQClient_1.connect();
MSMQClient_1.getMSMQMessage();
TestDB_1.getTEST1().insert();
TestDB_1.getTEST1().setTESTSTRING( "From JCD" );
TestDB_1.getTEST1().insertRow();
MSMQClient_1.getEwayConfiguration().setOutMSMQReceiveActionCode ( "ACTION_RECEIVE" );
MSMQClient_1.getMSMQMessage();
MSMQClient_1.disconnect();
} catch ( Exception Catch ) {
MSMQClient_1.disconnect();
}
The key code items are highlighted in bold. You must also use a try/catch block to catch the exception (for this example, the error is a failed insert to database).
MSMQ Share Mode- DENY_RECEIVE_SHARE: This locks the queue so that other applications cannot open the queue in Receive mode. Until your application closes the queue, no other application can open the queue to receive the message.
MSMQ Receive Action Code- ACTION_PEEK_CURRENT: This opens the queue so you can “peek” (view) the message.
MSMQClient_1.disconnect(). This closes the current queue instance and
unlocks the queue.