Package org.jboss.soa.esb.addressing

Examples of org.jboss.soa.esb.addressing.Call


    }
 
  private void setRelatesTo(Exchange exchange, Message esbMessage) throws MessageDeliverException {
    String exchangeId = (exchange != null ? exchange.getExchangeId() : null);
    if (exchangeId != null) {
      Call call = esbMessage.getHeader().getCall();
      URI relatesTo = call.getRelatesTo();
      if (relatesTo == null) {
        try {
          relatesTo = new URI(InVMEpr.INVM_PROTOCOL, "correlationID", exchangeId);
        } catch (URISyntaxException e) {
          throw new MessageDeliverException("problem creating relatesTo", e);
        }
        call.setRelatesTo(relatesTo);
      }
    }
  }
View Full Code Here


            // Try delivering the message using the courier we just looked up....

            if (courier != null) {
                // make sure the message header does not change when we exit
                final Call call = message.getHeader().getCall() ;
                final EPR currentToEpr = call.getTo() ;
                final EPR currentReplyToEpr = call.getReplyTo() ;

                try {
                    call.setTo(targetEPR);

                    final EPR replyToEPR ;
                    if (synchronous) {
                        /*
                         * Currently all couriers that have transactional semantics work in a manner similar
                         * to JMS, i.e., messages are not delivered on to a queue (or to an endpoint) until
                         * the enclosing transaction has committed. In a synchronous invocation this will
                         * result in timeouts if the sending thread is also the terminating thread. We check
                         * for this here and throw an exception before we try to do a send so the application can
                         * figure it out.
                         *
                         * Note: if the transactional semantics change (e.g., to support true distributed transactions)
                         * then this will need to be modified too.
                         */
                       
                        if (isTransactional())
                            throw new IncompatibleTransactionScopeException("Request-response attempt within running transaction controlling request delivery! Using epr [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]");
                       
                        replyToEPR = (currentReplyToEpr == null ? getReplyToAddress(targetEPR) : currentReplyToEpr) ;

                        if (replyToEPR == null) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Not using epr [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]. No reply-to address available for synchronous response.");
                            }
                            return null;
                        }
                        call.setReplyTo(replyToEPR);
                    } else {
                        replyToEPR = null ;
                    }
                    if (courier.deliver(message)) {
                        if (synchronous) {
                            courier.cleanup() ;
                            // JBESB-1016 replyToEPR has to be non-null or we'd have dropped out by this point!

                            // do we need to do this for synchronous calls? Vagueries of Couriers?

                            courier.setReplyToEpr(replyToEPR);
                            final Message response = courier.pickup(timeout);
                            if (response == null) {
                                throw new ResponseTimeoutException("No response received within timeout period") ;
                            }
                            return response ;
                        } else {
                            return message;
                        }
                    }
                } catch (FaultMessageException e) {
                    throw e;
                } catch (final CourierServiceBindException e) {
                    // meant to be masked by the SI fail-over

                    if (logger.isDebugEnabled()) {
                        logger.debug("Caught service lookup exception for EPR [" + targetEPR + "] and Service [" + service + "] and Message ["+message.getHeader()+"]. ", e);
                    }

                    // could be stale EPR, so move on to next entry in registry.
                } catch (final CourierMarshalUnmarshalException e) {
                    logger.warn("Courier indicated (un)marshal related error "+e+" during delivery to EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]. " + e.getMessage());

                    throw new MessageDeliverException("Caught (un)marshal related exception during attempted send/receive.", e);
                } catch (final CourierTransportException e) {
                    // meant to be masked by the SI fail-over

                    if (logger.isDebugEnabled()) {
                        logger.debug("Courier indicated transport related error "+e+" during send/receive with EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]. ", e);
                    }
                } catch (CourierException e) {
                    // probable config error. Log it and move on to next EPR/service entry.

                    logger.warn("Possible configuration error while using Courier for EPR [" + targetEPR + "] and Service [" + service + "] and Message ["+message.getHeader()+"]. " + e.getMessage());
                } catch (MalformedEPRException e) {
                    // Hmmmm???... Can this really happen?  The Courier has already been created.  Haven't we already validated the EPR during the Courier lookup (above)??
                    logger.error("Unexpected error.  Badly formed EPR [" + targetEPR + "] for Service [" + service + "]. But the EPR has already been validated!!");

                    throw e;
                } catch (final CourierTimeoutException ex) {
                    logger.error("Response timeout using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].");

                    // timeout from synchronous invocation
                   
                    // would like to make this an independent exception (not inherit from MDE). But signatures and applications would break.
                   
                    throw new ResponseTimeoutException("Caught response timeout!", ex);
                } catch (final MessageDeliverException mde) {
                    throw mde ;
                } catch (Throwable t) {
                    logger.error("Unexpected throwable during attempted message delivery using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].", t);

                    // we don't know what state we're in so better to bail-out now!

                    throw new MessageDeliverException("Caught unexpected throwable during send. Bailing-out!", t);
                } finally {
                    CourierUtil.cleanCourier(courier);

                    // put back the old To since we will have changed it.

                    call.setTo(currentToEpr) ;
                    call.setReplyTo(currentReplyToEpr) ;
                }
            }

            return null;
        }
View Full Code Here

      MalformedEPRException
  {
        if (null == _deliverCourier)
            throw new CourierException("No deliverAsync courier");
       
        final Call call = message.getHeader().getCall();
        call.setTo(_toEPR);

        final boolean setMessageID = call.getMessageID() == null;
        if (setMessageID) {
            final String messageID = UUID.randomUUID().toString();
            try {
                call.setMessageID(new URI(messageID));
            }
            catch (final URISyntaxException urise) {
                throw new MalformedEPRException("Failed to set message ID to " + messageID);
            }
        }

        try {
            message = FilterManager.getInstance().doOutputWork(message, null);

            return _deliverCourier.deliver(message);
        }
        finally {
            if (setMessageID) {
                call.setMessageID(null);
            }
        }
    }
View Full Code Here

    }

    public Message process(final Message message)
        throws ActionProcessingException
    {
        final Call call = message.getHeader().getCall() ;
        final EPR toEPR = call.getTo() ;
        final Iterator<Extension> extensions = toEPR.getAddr().getExtensions() ;
        if (extensions.hasNext())
        {
            final StringBuilder sb = new StringBuilder() ;
            do
View Full Code Here

public class CallUnitTest extends TestCase
{
  public void testConstructor ()
  {
    Call call = new Call();
   
    try
    {
      assertEquals((call.getTo() == null), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

  public void testEPRConstructor ()
  {
    try
    {
      EPR epr = new EPR(new URI("http://localhost"));
      Call call = new Call(epr);
     
      assertEquals(call.getTo().equals(epr), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

    }
  }
 
  public void testSetGetTo ()
  {
    Call call = new Call();
   
    try
    {
      EPR epr = new EPR(new URI("http://localhost"));
     
      call.setTo(epr);
     
      assertEquals(call.getTo().equals(epr), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

    }
  }
 
  public void testSetGetFrom ()
  {
    Call call = new Call();
   
    try
    {
      EPR epr = new EPR(new URI("http://localhost"));
     
      call.setFrom(epr);
     
      assertEquals(call.getFrom().equals(epr), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

    }
  }
 
  public void testSetGetReplyTo ()
  {
    Call call = new Call();
   
    try
    {
      EPR epr = new EPR(new URI("http://localhost"));
     
      call.setReplyTo(epr);
     
      assertEquals(call.getReplyTo().equals(epr), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

    }
  }
 
  public void testSetGetFaultTo ()
  {
    Call call = new Call();
   
    try
    {
      EPR epr = new EPR(new URI("http://localhost"));
     
      call.setFaultTo(epr);
     
      assertEquals(call.getFaultTo().equals(epr), true);
    }
    catch (Exception ex)
    {
      fail(ex.toString());
    }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.addressing.Call

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.