I'm writing a pub/sub server that, on receiving an incoming message,
stores it into a messageArray, and then creates a thread to forward
messages in the array. The following code works ok if the "forwardMessage"
method is called within onMessage(); messages get delivered.

But whenever I try to deliver the messages in messageArray using a thread
as shown below, I get the following exception and messages don't get

ReplyMsgBean.forwardMessage: JMSException:
com.sun.messaging.jms.JMSException: [SEND_REPLY(9)] [C4036]: A server
error occurred. : transaction failed: Unexpected Broker Exception:
[received message with Unknown Transaction ID -1: ignoring message]

It looks like the server could not create the connection within the
forwardMessage method.

I'd appreciate any suggestions.




public class ReplyMsgBean implements MessageDrivenBean, MessageListener {
    public ReplyMsgBean() throws Exception {
 messageArray = new ArrayList();
 mft = new MessageForwardingThread();
    public void ejbCreate() {
        try {
            Context initial = new InitialContext();
            cf = (ConnectionFactory) initial.lookup(
        } catch (Exception ex) {
            logger.severe("ReplyMsgBean.ejbCreate: Exception: " +
    public void onMessage(Message inMessage) {
       put the message into messageArray
    private static void forwardMessage(TextMessage msg) {
         Connection con = cf.createConnection();
         Session ses = con.createSession(true, 0);
         producer = ses.createProducer(topic);

   final class MessageForwardingThread extends Thread {
 public final void run() {
             for every-message (msg) in messageArray



To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to