Hi Ramesh,
ATM there is only one resource in the transaction. So maybe 2pc is not
needed - I'm not sure about this.
But it should work anyway, shouldn't it?
Scenario:
- Putting a TextMessage into a Sonic Queue via Glassfish -> genericra -> Sonic
- Receiving this Message via Sonic -> genericra -> Glassfish-MDB
What happens is:
- we're seeing the Queue contains one Message on the Sonic
- the onMessage() of the MDB is called and executed successfully
- we're seeing the Queue is empty again on the Sonic, so it seems like
the messages got delivered successfully
- we are stopping Glassfish
-> the Queue is full again on the Sonic! After Starting Glassfish
again, the message that was already delivered before is delivered
again, which is OK. But it shouldn't be there anymore.
We're sending the TextMessage via RESTful WebService:
@Stateless
@Path("/jms")
public class JMSRestfulWebService {
@Resource(mappedName = "OurConnectionFactory_int")
private ConnectionFactory sonicConnectionFactory;
@Resource(mappedName = "aQueue")
private Queue sonicQueue;
@Path("sonic")
@GET
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String putMessageSonic() throws NamingException, JMSException,
NotSupportedException, SystemException, SecurityException,
IllegalStateException, RollbackException, HeuristicMixedException,
HeuristicRollbackException
{
System.out.println("called putMessageAdapter->Sonic");
javax.jms.Connection connection = null;
javax.jms.Session session = null;
MessageProducer messageProducer = null;
try
{
connection = sonicConnectionFactory.createConnection();
session = connection.createSession(true,0);
messageProducer = session.createProducer(sonicQueue);
TextMessage message = session.createTextMessage();
message.setText("Hello, sonic JMS! #");
messageProducer.send(message);
return "JMS remotely produced 1 message for sonic #;
}
finally
{
if (messageProducer != null) try { messageProducer.close(); }
catch (Exception ignore) { }
if (session != null) try { session.close(); } catch (Exception ignore) { }
if (connection != null) try { connection.close(); } catch
(Exception ignore) { }
}
}
}
And this is our configuration, Glassfish-side
asadmin deploy \temp\genericra\genericra.rar
asadmin create-resource-adapter-config --property
UseFirstXAForRedelivery=true:SupportsXA=true:ProviderIntegrationMode=jndi:UserName=user:Password=secret:JndiProperties=java.naming.factory.initial\=com.sonicsw.jndi.mfcontext.MFContextFactory,java.naming.provider.url\=tcp\://localhost\:13508,com.sonicsw.jndi.mfcontext.domain\=dmOttoDev,java.naming.security.principal\=user,java.naming.security.credentials\=secret:LogLevel=FINEST
genericra
asadmin create-connector-connection-pool --raname genericra
--connectiondefinition javax.jms.XAQueueConnectionFactory
--transactionsupport XATransaction --property
ConnectionFactoryJndiName=NoaConnectionFactory_int
NoaConnectionFactory_intCP
asadmin create-connector-resource --poolname
NoaConnectionFactory_intCP NoaConnectionFactory_int
asadmin create-admin-object --raname genericra --restype
javax.jms.Queue --property DestinationJndiName=aHolger aHolger
> Could you please find out the status of the transactions (COMPLETED / PENDING/STARTED ) from Sonic MQ before stopping GlassFish.
I don't know how to do this :(.
-Matthias