2 Replies Latest reply: Sep 22, 2006 3:02 AM by BKBK RSS

    Possible corrections for the JMS Gateway code?

    BKBK Community Member
      The JMS specifications require the JMS Provider to set the client ID by default, not the client to set his own ID. Coldfusion's code will therefore generate an Exception with most JMS servers.

      To correct the problem, comment out the following lines of code

      JMSConsumer.java
      ------------------------------
      this.connection.setClientID(this.configuration.getSubscriberName());

      JMSPublishConnection.java
      ------------------------------------------
      this.connection.setClientID(this.configuration.getPublisherName(this.topicName));

      The following code snippet from JMSGateway.java looks very much like an error

      if (sendMessage(cfMsg))
      {
      log.info("Added message '" + msgID + "' to queue.");
      }

      I think it should be something like

      boolean messageSent = gatewayService.addEvent(cfMsg);
      if (messageSent)
      {
      log.info("Added message '" + msgID + "' to queue.");
      }


        • 1. Possible corrections for the JMS Gateway code?
          BKBK Community Member
          My suggested correction for the JMSGateway.java code assumes that the variable gatewayService has already been defined. However, the current code doesn't define it.

          Here follows a suggestion that doesn't assume that gatewayService is defined beforehand.

          1) Add the following line to the JMSGateway.java code:

          import coldfusion.eventgateway.GatewayServices;

          2) Modify the code snippet in my original post to

          boolean messageSent = (boolean) GatewayServices.getGatewayServices().addEvent(cfMsg);
          if (messageSent)
          {
          log.info("Added message '" + msgID + "' to queue.");
          }

          3) Added edit:

          (a) You may have to add the following lines at the appropriate places:

          private String gatewayID; (add it where the other private variables are declared)

          this.gatewayID = gatewayID; (add it just under the line super(gatewayID);)

          (b) Replace the line CFEvent cfMsg = new CFEvent(getGatewayID()); with

          CFEvent cfMsg = new CFEvent(gatewayID);



          • 2. Re: Possible corrections for the JMS Gateway code?
            BKBK Community Member
            To correct the problem, comment out the following lines of code...

            Perhaps too drastic. It would be more graceful to use try/catch instead, especially as a durable subscriber may have occasion to call setClientID(). Thus, for example, in JMSConsumer.java, do

            try {
            this.connection.setClientID(this.configuration.getSubscriberName());
            }catch (IllegalStateException e) {System.out.println(e);}



            Thanks to Sean Corfield for the remark