Package javax.jbi.messaging

Examples of javax.jbi.messaging.DeliveryChannel


            inonly.setInMessage(msg);
            channel.send(inonly);
        }
       
        public Source twoWay(Source src) throws Exception {
            DeliveryChannel channel = context.getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOut inout = factory.createInOutExchange();
            inout.setService(ReceiverComponent.SERVICE);
            NormalizedMessage msg = inout.createMessage();
            msg.setContent(src);
            inout.setInMessage(msg);
            channel.sendSync(inout);
            Source outSrc = inout.getOutMessage().getContent();
            inout.setStatus(ExchangeStatus.DONE);
            channel.send(inout);
            return outSrc;
        }
View Full Code Here


     * Gets the delivery channel.
     *
     * @return delivery channel
     */
    public DeliveryChannel getChannel() {
        DeliveryChannel chnl = null;

        if (_context != null) {
            try {
                chnl = _context.getDeliveryChannel();
            } catch (Exception e) {
View Full Code Here

        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOnly exchange = factory.createInOnlyExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
        } catch (XFireFault e) {
            throw e;
View Full Code Here

        }
        try {
          if (soapAction != null) {
            XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
          }
            DeliveryChannel channel = getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            InOut exchange = factory.createInOutExchange();
            populateExchange(exchange, source, context);
            boolean result = channel.sendSync(exchange);
            if (!result) {
                throw new XFireFault("Error sending exchange", XFireFault.SENDER);
            }
            if (exchange.getStatus() == ExchangeStatus.ERROR) {
                Exception e = exchange.getError();
                if (e == null) {
                    throw new XFireFault("Received error", XFireFault.SENDER);
                } else {
                    throw new XFireFault(e, XFireFault.SENDER);
                }
            }
            NormalizedMessage outMessage = exchange.getOutMessage();
            if (outMessage == null) {
                exchange.setError(new Exception("Expected an out message"));
                channel.sendSync(exchange);
                throw new XFireFault("No response", XFireFault.SENDER);
            }                   
            Source src = exchange.getOutMessage().getContent();
            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);
            src = transformer.toDOMSource(src);
            return src;
        } catch (XFireFault e) {
            throw e;
        } catch (Exception e) {
View Full Code Here

    }

    // Helper methods for the rule base
    //-------------------------------------------------------------------------
    public void forwardToService(MessageExchange exchange, NormalizedMessage in, QName name) throws MessagingException {
        DeliveryChannel channel = getDeliveryChannel();
        MessageExchangeFactory factory = channel.createExchangeFactoryForService(name);
        InOnly outExchange = factory.createInOnlyExchange();
        String processCorrelationId = (String)exchange.getProperty(JbiConstants.CORRELATION_ID);
        if (processCorrelationId != null) {
            outExchange.setProperty(JbiConstants.CORRELATION_ID, processCorrelationId);
        }
View Full Code Here

        }
        forwardToExchange(exchange, outExchange, in);
    }

    public void forwardToInterface(QName name, MessageExchange exchange, NormalizedMessage in) throws MessagingException {
        DeliveryChannel channel = getDeliveryChannel();
        MessageExchangeFactory factory = channel.createExchangeFactory(name);
        InOnly outExchange = factory.createInOnlyExchange();
        String processCorrelationId = (String)exchange.getProperty(JbiConstants.CORRELATION_ID);
        if (processCorrelationId != null) {
            outExchange.setProperty(JbiConstants.CORRELATION_ID, processCorrelationId);
        }
View Full Code Here

    public void route(MessageExchange exchange, NormalizedMessage in, QName service, QName interfaceName, QName operation) throws MessagingException {
        if (routed.get() != null) {
            throw new IllegalStateException("Drools component has already routed this exchange");
        }
        routed.set(Boolean.TRUE);
        DeliveryChannel channel = getDeliveryChannel();
        MessageExchangeFactory factory = channel.createExchangeFactory();
        MessageExchange me = factory.createExchange(exchange.getPattern());
        me.setInterfaceName(interfaceName);
        me.setService(service);
        me.setOperation(operation);
        NormalizedMessage nm = me.createMessage();
        me.setMessage(nm, "in");
        getMessageTransformer().transform(exchange, in, nm);
        channel.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, me.getError());
        } else if (me.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else {
            NormalizedMessage out = me.getMessage("out");
            if (out != null) {
                nm = exchange.createMessage();
                exchange.setMessage(nm, "out");
                getMessageTransformer().transform(exchange, out, nm);
            } else {
                Fault f = me.getFault();
                Fault of = exchange.createFault();
                exchange.setFault(of);
                getMessageTransformer().transform(exchange, f, of);
            }
            channel.send(exchange);
            done(me);
        }
       
    }
View Full Code Here

      if (folder == null || !folder.exists()) {
        throw new Exception("Folder not found or invalid: " + mailBox);
      }
      folder.open(Folder.READ_WRITE);
      int msgCount = Math.min(folder.getMessageCount(),maxFetchSize);
      DeliveryChannel channel = getDeliveryChannel();
      MessageExchangeFactory mef = getExchangeFactory();
        for(int i=1; i <= msgCount;i++) {
          MimeMessage mailMsg = (MimeMessage) folder.getMessage(i);
          InOnly io = mef.createInOnlyExchange();
          NormalizedMessage normalizedMessage = io.createMessage();
          this.marshaler.prepareExchange(io,normalizedMessage,mailMsg);
          io.setInMessage(normalizedMessage);
          channel.send(io);
            mailMsg.setFlag(Flags.Flag.DELETED,true);
        }
    } finally {
      try {
        if (folder != null) {
View Full Code Here

    /**
     * Sends a number of messages
     */
    public void sendMessages(int count) throws MessagingException {
        DeliveryChannel deliveryChannel = context.getDeliveryChannel();
        MessageExchangeFactory factory = deliveryChannel.createExchangeFactory();

        for (int i = 0; i < count; i++) {
            InOnly exchange = factory.createInOnlyExchange();
            NormalizedMessage message = exchange.createMessage();
            exchange.setInMessage(message);

            message.setProperty("id", new Integer(i));
            message.setContent(new StringSource("<example id='" + i + "'/>"));

            deliveryChannel.send(exchange);
        }
    }
View Full Code Here

    /**
     * Runnable implementation
     */
    public void run() {
        try {
            DeliveryChannel deliveryChannel = getDeliveryChannel();
            while (!stop.get()) {
                MessageExchange exchange = deliveryChannel.accept();
                if (exchange != null) {
                    try {
                        onMessageExchange(exchange);
                    } catch (MessagingException e) {
                        LOGGER.error("MessageExchange processing failed", e);
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.DeliveryChannel

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.