Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
JMS - UserTransaction - Commit issue

546634
Member Posts: 23
Introduction
--------------------------------------------------------------------------------
I am moving from WebSphere to Weblogic and have counterd an UserTransaction commit issue.
The code have not been modified, however the logic in Weblogic and Websphere behaves different.
The messagingsystem is Websphere MQ, in Weblogic I have QCF, destinations, host and port etc. in a .bindings file, and I have configured JMS server and JMS modules with corresponding jndi names.
I have verified that this configuration is correct throug a custom develop testtool deployed in WL, message is sent successfully to MQ.
The problem - description
--------------------------------------------------------------------------------
However in my application i'm using UserTransaction and this is not working as expected.
I have two classes that communicate with MQ (AbcDAO.java and QueueBroker.java) AbcDAO.java creates a UserTransaction and communicates with Queuebroker throug a method called "SendToAutoS" this method retrives the corrilationId (for the message sendt to MQ) from Queuebroker.
The SendMessage method creates qcf, queueconnection, queue etc and sends the message to MQ. When i debug this steps (line:queueSender.send(theMessage) I can verify in MQ that a message count is registerted in mq on the correct queue, but it's not shown (since its not commited). However when performing finalize in Queuebroker, which close both session and connection, the messagecount is gone in MQ, and when returing to AbcDAO.java to perform ut.commit(); there is not any message on Queue.
For me it looks like the message is rolledback when session and connection closes.
Actions tried
--------------------------------------------------------------------------------
If I change this line QueueBroker , transacted to false witch i understand sends message without the need to commit:
boolean transacted = false;
queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);
the message is sendt successfully to MQ. However now either commit or rollback on the UserTransaction is working with transacted=false.
I need the commit and rollback to be done on the UserTransaction for my application.
Anyone have an idea why this is not working?
The files - content
--------------------------------------------------------------------------------
AbcDAO.java - that creates a usertransaction
--------------------------------------------------------------------------------
ut = ServiceLocator.getInstance().getUserTransaction();
ut.begin();
msgCorId = sendToAutoS(userVO, messageSend, transactionQeueSend, transactionQeueFactory);
ut.commit();
//SendToAutoS - that calls the Queuebroker method - sendMessage
private String sendToAutoS(UserVO userVO, String message, String transactionQueue, String transactionQueueFactory) throws DaoException {
try {
log.debug("..");
return QueueBroker.getInstance().sendMessage(message, transactionQueue, transactionQueueFactory);
} catch (BrokerException be) {
log.error("BrokerException", be);
...
..
}
}
QueueBroker.java - that sends the message to MQ
--------------------------------------------------------------------------------
public String sendMessage(String message, String transactionQueue, String transactionQueueFactory) throws BrokerException {
try {
// Get service locator
ServiceLocator sl = ServiceLocator.getInstance();
// Create QueueConnectionFactory with help form service locator
queueConnectionFactory = (QueueConnectionFactory) sl.getQueueConnectionFactory(transactionQueueFactory);
// Create QueueConnection
queueConnection = queueConnectionFactory.createQueueConnection();
// Create QueueSession, transacted - client has to commit !
boolean transacted = true;
queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);
// Create queue with help from service locator
queue = (Queue) sl.getQueue(transactionQueue);
// Create QueueSender
queueSender = queueSession.createSender(queue);
// Create message and sent it
Message theMessage = null;
theMessage = queueSession.createTextMessage(message);
// Log time
long time = System.currentTimeMillis();
// Set log time on message
theMessage.setJMSTimestamp(time);
// Send
queueSender.send(theMessage);
queueSender.close();
// Return unique messageID for message just been sent
return theMessage.getJMSMessageID();
} catch (JMSException je) {
BrokerException ex = new BrokerException();
ex.setMessageKey("requisition.jms.broker.queue");
Object[] o = {"SEND", "String to Autosys = " + message};
ex.setMessageArgs(o);
ex.setRootCause(je);
throw ex;
} catch (ServiceLocatorException e) {
BrokerException ex = new BrokerException();
ex.setMessageKey(e.getMessageKey());
ex.setMessageArgs(e.getMessageArgs());
ex.setRootCause(e.getRootCause());
throw ex;
} finally {
// Clean up - close connection and session if exist
if (queueConnection != null) {
finalize();
}
}
}
/**
* Finalize queue handling
*
* @throws BrokerException e
*/
protected void finalize() throws BrokerException {
try {
// Close connections
queueSession.close();
queueConnection.close();
} catch (JMSException je) {
BrokerException ex = new BrokerException();
ex.setMessageKey("requisition.jms.broker.queue");
Object[] o = {"FINALIZE", "Close connections" };
ex.setMessageArgs(o);
ex.setRootCause(je);
throw ex;
}
}
Edited by: reZer on 14.sep.2011 13:05
Edited by: reZer on 14.sep.2011 13:06
--------------------------------------------------------------------------------
I am moving from WebSphere to Weblogic and have counterd an UserTransaction commit issue.
The code have not been modified, however the logic in Weblogic and Websphere behaves different.
The messagingsystem is Websphere MQ, in Weblogic I have QCF, destinations, host and port etc. in a .bindings file, and I have configured JMS server and JMS modules with corresponding jndi names.
I have verified that this configuration is correct throug a custom develop testtool deployed in WL, message is sent successfully to MQ.
The problem - description
--------------------------------------------------------------------------------
However in my application i'm using UserTransaction and this is not working as expected.
I have two classes that communicate with MQ (AbcDAO.java and QueueBroker.java) AbcDAO.java creates a UserTransaction and communicates with Queuebroker throug a method called "SendToAutoS" this method retrives the corrilationId (for the message sendt to MQ) from Queuebroker.
The SendMessage method creates qcf, queueconnection, queue etc and sends the message to MQ. When i debug this steps (line:queueSender.send(theMessage) I can verify in MQ that a message count is registerted in mq on the correct queue, but it's not shown (since its not commited). However when performing finalize in Queuebroker, which close both session and connection, the messagecount is gone in MQ, and when returing to AbcDAO.java to perform ut.commit(); there is not any message on Queue.
For me it looks like the message is rolledback when session and connection closes.
Actions tried
--------------------------------------------------------------------------------
If I change this line QueueBroker , transacted to false witch i understand sends message without the need to commit:
boolean transacted = false;
queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);
the message is sendt successfully to MQ. However now either commit or rollback on the UserTransaction is working with transacted=false.
I need the commit and rollback to be done on the UserTransaction for my application.
Anyone have an idea why this is not working?
The files - content
--------------------------------------------------------------------------------
AbcDAO.java - that creates a usertransaction
--------------------------------------------------------------------------------
ut = ServiceLocator.getInstance().getUserTransaction();
ut.begin();
msgCorId = sendToAutoS(userVO, messageSend, transactionQeueSend, transactionQeueFactory);
ut.commit();
//SendToAutoS - that calls the Queuebroker method - sendMessage
private String sendToAutoS(UserVO userVO, String message, String transactionQueue, String transactionQueueFactory) throws DaoException {
try {
log.debug("..");
return QueueBroker.getInstance().sendMessage(message, transactionQueue, transactionQueueFactory);
} catch (BrokerException be) {
log.error("BrokerException", be);
...
..
}
}
QueueBroker.java - that sends the message to MQ
--------------------------------------------------------------------------------
public String sendMessage(String message, String transactionQueue, String transactionQueueFactory) throws BrokerException {
try {
// Get service locator
ServiceLocator sl = ServiceLocator.getInstance();
// Create QueueConnectionFactory with help form service locator
queueConnectionFactory = (QueueConnectionFactory) sl.getQueueConnectionFactory(transactionQueueFactory);
// Create QueueConnection
queueConnection = queueConnectionFactory.createQueueConnection();
// Create QueueSession, transacted - client has to commit !
boolean transacted = true;
queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);
// Create queue with help from service locator
queue = (Queue) sl.getQueue(transactionQueue);
// Create QueueSender
queueSender = queueSession.createSender(queue);
// Create message and sent it
Message theMessage = null;
theMessage = queueSession.createTextMessage(message);
// Log time
long time = System.currentTimeMillis();
// Set log time on message
theMessage.setJMSTimestamp(time);
// Send
queueSender.send(theMessage);
queueSender.close();
// Return unique messageID for message just been sent
return theMessage.getJMSMessageID();
} catch (JMSException je) {
BrokerException ex = new BrokerException();
ex.setMessageKey("requisition.jms.broker.queue");
Object[] o = {"SEND", "String to Autosys = " + message};
ex.setMessageArgs(o);
ex.setRootCause(je);
throw ex;
} catch (ServiceLocatorException e) {
BrokerException ex = new BrokerException();
ex.setMessageKey(e.getMessageKey());
ex.setMessageArgs(e.getMessageArgs());
ex.setRootCause(e.getRootCause());
throw ex;
} finally {
// Clean up - close connection and session if exist
if (queueConnection != null) {
finalize();
}
}
}
/**
* Finalize queue handling
*
* @throws BrokerException e
*/
protected void finalize() throws BrokerException {
try {
// Close connections
queueSession.close();
queueConnection.close();
} catch (JMSException je) {
BrokerException ex = new BrokerException();
ex.setMessageKey("requisition.jms.broker.queue");
Object[] o = {"FINALIZE", "Close connections" };
ex.setMessageArgs(o);
ex.setRootCause(je);
throw ex;
}
}
Edited by: reZer on 14.sep.2011 13:05
Edited by: reZer on 14.sep.2011 13:06
Answers
-
I know you are trying to send a JMS message, but just because this is true the generic JMS forum is not automatically the place you should ask questions like this. Your real beef is with the container you are using (Weblogic), UserTransaction and persistent JMS messages in combination with the specific JMS provider you are using.
You will have far more chance to get help with this problem if you ask it in the Weblogic forum which you can also find on this very website. If you make a new post, be sure to create a link to it here so people can follow it.
https://forums.oracle.com/forums/category.jspa?categoryID=193
And perhaps more specific:
3833 -
Are your JMS connections XA?
-
Yes, its XA
This discussion has been closed.