0 Replies Latest reply on Apr 24, 2010 2:33 AM by patelbharat2210

    fs-listener composer-class configuration exception

    patelbharat2210

      Hi all,

       

      I am new to ESB. I have a special requirement where in I have to compose and new MessageComposer class and that will read a two files with different extensions from the file system. Of which one file content has to be added as body and the other file has to be added as attachment. Aftter this in the action the action class will store the body of the Message into a file on the particular folder and pass on the message.  I have written the below class and the jboss-esb.xml. When I deploy I am getting ConfigurationException

       

      Caused by: org.jboss.soa.esb.ConfigurationException: Failed to instantiate composer class [com.progratorgatetrade.filestore.message.FileStoreMessageCompose].
          at org.jboss.soa.esb.listeners.message.MessageComposer$Factory.newComposerInstance(MessageComposer.java:134)
          at org.jboss.soa.esb.listeners.message.MessageComposer$Factory.getInstance(MessageComposer.java:110)
          at org.jboss.soa.esb.listeners.gateway.AbstractFileGateway.checkMyParms(AbstractFileGateway.java:279)
          at org.jboss.soa.esb.listeners.gateway.AbstractFileGateway.<init>(AbstractFileGateway.java:88)
          at org.jboss.soa.esb.listeners.gateway.FileGatewayListener.<init>(FileGatewayListener.java:45)
          ... 126 more

       

      here is my jboss-esb.xml

       

      <?xml version="1.0"?>
      <jbossesb parameterReloadSecs="5"
          xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
          <providers>
              <fs-provider name="fileSystemProvider">
                  <fs-bus busid="fileSystemBus">
                      <fs-message-filter directory="some-local-dir"
                          input-suffix=".dat" />
                  </fs-bus>
              </fs-provider>
              <jms-provider connection-factory="ConnectionFactory"
                  name="JBossMessaging">
                  <jms-bus busid="senderEsbBus">
                      <jms-message-filter dest-name="queue/sender_mailbox"
                          dest-type="QUEUE" />
                  </jms-bus>
              </jms-provider>
          </providers>
          <services>
              <service category="FileStoreCategory" description="Listens to the file from a directory"
                  name="FileStoreListener">
                  <listeners>
                      <fs-listener busidref="fileSystemBus" is-gateway="true"
                          maxThreads="1" name="FileGateway" poll-frequency-seconds="10">
                          <property name="composer-class"
                              value="com.progratorgatetrade.filestore.message.FileStoreMessageCompose"></property>
                      </fs-listener>
                      <jms-listener busidref="senderEsbBus" name="fileStoreQueueListener" />
                  </listeners>
                  <actions mep="OneWay">
                      <action
                          name="fileStoreAction" process="persistFileToFileStore">
                          <property name="fileStorePath" value="some-local-dir" />
                          <property name="filePrefix" value="payload_saved_"></property>
                          <property name="fileSuffix" value=".dat"></property>
                      </action>
                  </actions>
              </service>
          </services>
      </jbossesb>

       

       

      here is the composer class

       

      public class FileStoreMessageCompose<T extends File> implements
              MessageComposer<T> {

       

          public static final String PROP_FILE_OBJ = "in-file-obj";
          public static final String PROP_FILE_PATH = "in-file-path";
          public static final String PROP_FILE_LENGTH = "in-file-length";
          public static final String PROP_FILE_LASTMOD = "in-file-lastmod";

       

          private MessagePayloadProxy payloadProxy;

       

          public FileStoreMessageCompose(ConfigTree configTree) {
              System.out.println("FileStoreMessageCompose Constructor Called");
          }

       

          @Override
          public Message compose(T inputFile) throws MessageDeliverException {

       

              System.out.println("Cmposing the message");
              MessageFactory messageFactory = MessageFactory.getInstance();
              Message esbMessage = messageFactory.getMessage();

       

              if (inputFile.isDirectory()) {
                  File[] files = inputFile.listFiles();
                  if (files.length != 0) {
                      for (File file : files) {

       

                          if (file.getName().endsWith(".dat")) {
                              try {
                                  payloadProxy.setPayload(esbMessage, FileUtil
                                          .readFile(file));
                              } catch (IOException e) {
                                  System.out
                                          .println("IO Exception reading the files");
                              }
                          }

       

                          if (file.getName().endsWith(".xml")) {
                              esbMessage.getAttachment().addItem(file);
                          }
                      }
                  }
              } else {
                  throw new MessageDeliverException("Invalid File payload.  File '"
                          + inputFile.getAbsolutePath() + "' doesn't exist.");

       

              }

       

              esbMessage.getProperties().setProperty(PROP_FILE_OBJ, inputFile);
              esbMessage.getProperties().setProperty(PROP_FILE_PATH,
                      inputFile.getAbsolutePath());
              esbMessage.getProperties().setProperty(PROP_FILE_LENGTH,
                      inputFile.length());
              esbMessage.getProperties().setProperty(PROP_FILE_LASTMOD,
                      inputFile.lastModified());

       

              System.out.println("Composing message complete");
              return esbMessage;
          }

       

          @Override
          public Object decompose(Message message, T arg1)
                  throws MessageDeliverException {
              System.out.println("Decomposing the message");
              return payloadProxy.getPayload(message);
          }

       

          @Override
          public void setConfiguration(ConfigTree arg0) throws ConfigurationException {
              System.out.println("Setting the configuration");

       

              payloadProxy = new MessagePayloadProxy(arg0);

       

          }
      }

       

      I am using JBoss ESB 4.3 Anyone please help me in this regard.

      Thanks in advance

       

      Regards

       

      Bharat Patel