Package net.sf.xbus.protocol

Examples of net.sf.xbus.protocol.Message


    DeletedMessageStore dms = DeletedMessageStore.getInstance();
    dms.setMessage(request);
    dms.setSystem(source);

    mReturncode = Constants.RC_NOK;
    Message call = null;
    try
    {
      try
      {
        // Zero: check handling of empty messages
        if (!checkRequest(source, request))
        {
          /*
           * Request shall not be processed but ignored
           */
          call = new SimpleTextMessage(source);
          try
          {
            ((TextMessage) call).setRequestText(request.toString(),
                source);
          }
          catch (XException e)
          {
            // This problem has already been traced
          }
          call.setReturncode(Constants.RC_OK);
        }
        else
        {
          /*
           * Request shall be processed
           */

          // First: create the message obejct
          call = MessageFactory.createApplicationMessage(source);

          // Second: initialise the message object by pasting in the
          // request
          // as content,
          // then perfom the call the appropriate application object
          // and record the response
          if (Constants.TYPE_TEXT.equals(messageType))
          {
            ((TextMessage) call).setRequestText((String) request,
                source);
            ApplicationFactory.callApplication(call);
            // Get the response.
            // The message is already transformed and structure
            // information
            // for serialising is attached to the source system.
            mResponse = ((TextMessage) call).getResponseText();
          }
          else if (Constants.TYPE_OBJECT.equals(messageType))
          {
            ((ObjectMessage) call)
                .setRequestObject(request, source);
            ApplicationFactory.callApplication(call);
            // Get the response.
            // The message is already transformed and structure
            // information
            // for serialising is attached to the source system.
            mResponse = ((ObjectMessage) call).getResponseObject();
          }
        }
      }
      catch (Exception t)
      {
        /*
         * Inner try-catch block catches all exceptions and converts
         * them to XExceptions if necessary
         */
        if (t instanceof XException)
        {
          throw (XException) t;
        }
        else
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_APPLICATION,
              Constants.PACKAGE_APPLICATION_ADAPTER, "0", t);
        }
      }
    }
    catch (XException e)
    {
      /*
       * Outer try-catch block handles the XException
       */
      if (call == null)
      {
        if (request == null)
        {
          request = "<null>";
        }
        call = new SimpleTextMessage(source);
        try
        {
          ((TextMessage) call).setRequestText(request.toString(),
              source);
        }
        catch (XException e1)
        {
          // This problem has already been traced
        }
      }
      call.setReturncode(Constants.RC_NOK);
      if ((call.getErrortext() == null)
          || (call.getErrortext().length() == 0))
      {
        call.setErrortext(e.getMessage());
      }
    }
    finally
    {
      mReturncode = call.getReturncode();
      mErrormessage = call.getErrortext();

      try
      {
        // Logging of the receiving-activity into the journal and
        // closing the
        // connection to the database.
        call.setResponseTimestamp(new Date());
        Journal journal = new Journal();
        journal.log('R', source, call);
        journal.commit();
      } // try
      catch (Exception t)
View Full Code Here


   */
  public void invokeAndDistribute(Message message) throws XException
  {
    InvokeInternalResult invokeResult = invokeInternal(message);

    Message newMessage = invokeResult.resultMessage;

    if (newMessage.getReturncode() == Constants.RC_OK)
    {
      distributeInternal(newMessage);
    }

    message.setReturncode(newMessage.getReturncode());
    message.setErrorcode(newMessage.getErrorcode());
    message.setErrortext(newMessage.getErrortext());
  }
View Full Code Here

   */
  public void invoke(Message message) throws XException
  {
    InvokeInternalResult invokeResult = invokeInternal(message);

    Message newMessage = invokeResult.resultMessage;
    XBUSSystem lastSystem = invokeResult.lastSystem;

    MessageFactory.transformResponse2Response(lastSystem, message
        .getSource(), newMessage, message);
  }
View Full Code Here

    String destString = getRouterEntry(message, "Distribute1");
    XBUSSystem destination;

    int countSystems = 1;
    boolean rollback = false;
    Message sendMessage = null;

    while ((destString != null) && (!rollback))
    {
      sendMessage = null;
      Configuration config = Configuration.getInstance();
      destination = new XBUSSystem(destString, message.getSource()
          .getAddresses(), config.getValueAsBooleanOptional("System",
          destString, "Broadcast"));
      // The last parameter instructs the sender to try a broadcast for
      // all configured addtional addresses. This will only be active if
      // the destination address really contains a reference to the
      // addtional address information.
      try
      {
        if (mResponseFilled)
        {
          sendMessage = MessageFactory.createSenderMessage(
              destination, message,
              MessageFactory.TRANSFORM_FROM_RESPONSE);
        }
        else
        {
          sendMessage = MessageFactory.createSenderMessage(
              destination, message,
              MessageFactory.TRANSFORM_FROM_REQUEST);
        }

        Adapter.callSender(sendMessage, destination);

        if (!Constants.RC_OK.equals(sendMessage.getReturncode()))
        {
          rollback = true;
        }
      }
      catch (XException e)
      {
        rollback = true;
        errortext = e.getMessage();
        Trace.error("Exception while routing messages");
      }
      countSystems++;
      destString = getRouterEntryOptional(message,
          new StringBuffer().append("Distribute")
              .append(countSystems).toString());
    }

    if (rollback)
    {
      if (sendMessage != null)
      {
        message.setReturncode(sendMessage.getReturncode());
        message.setErrorcode(sendMessage.getErrorcode());
        message.setErrortext(sendMessage.getErrortext());
      }
      else
      {
        message.setReturncode(Constants.RC_NOK);
        if (errortext != null)
View Full Code Here

    String destString = getRouterEntry(message,  "Invoke1");

    int countSystems = 1;
    boolean rollback = false;

    Message sendMessage = message;
    Message sendMessageNew = null;

    while ((destString != null) && (!rollback))
    {
      result.lastSystem = new XBUSSystem(destString, message.getSource()
          .getAddresses());
      try
      {
        if (countSystems == 1)
        {
          sendMessageNew = MessageFactory.createSenderMessage(
              result.lastSystem, sendMessage,
              MessageFactory.TRANSFORM_FROM_REQUEST);
        }
        else
        {
          sendMessageNew = MessageFactory.createSenderMessage(
              result.lastSystem, sendMessage,
              MessageFactory.TRANSFORM_FROM_RESPONSE);
        }

        Adapter.callSender(sendMessageNew, result.lastSystem);

        if (!sendMessageNew.getReturncode().equals(Constants.RC_OK))
        {
          rollback = true;
        }

        sendMessage = sendMessageNew;
View Full Code Here

                "is empty") == -1)
        {
          /**
           * Send error message to various systems
           */
          Message sendMessage = null;
          XBUSSystem notifySystem = null;

          notifySystemName = config.getValueOptional("Base",
              "NotifyError", Constants.CHAPTER_SYSTEM + "1");
          if (notifySystemName != null)
View Full Code Here

TOP

Related Classes of net.sf.xbus.protocol.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.