/** * Creates an InOut exchange and propagates the correlation id from the given exchange * to the newly created exchange * @param srcExchange * @return InOut * @throws MessagingException */ public InOut createInOutExchange(MessageExchange srcExchange) throws MessagingException { MessageExchangeFactory factory = getExchangeFactory(); InOut inOut = factory.createInOutExchange(); propagateCorrelationId(srcExchange, inOut); return inOut; }
/** * Creates an InOut exchange and propagates the correlation id from the given exchange * to the newly created exchange * @param srcExchange * @return InOut * @throws MessagingException */ public InOut createInOutExchange(MessageExchange srcExchange) throws MessagingException { MessageExchangeFactory factory = getExchangeFactory(); InOut inOut = factory.createInOutExchange(); propagateCorrelationId(srcExchange, inOut); return inOut; }
public InOut createInOutExchange() throws MessagingException { InOut exchange = getExchangeFactory().createInOutExchange(); NormalizedMessage in = exchange.createMessage(); exchange.setInMessage(in); return exchange; }
public Message sendReceive(Message message) throws ClientException { if (logger.isLoggable(Level.FINE)) { logger.fine("SendReceive message"); } Message result = null; // create a internal message from the given one... try { MessageExchange messageExchange = this.messageExchangeFactory.createInOutExchange(); Document out = this.send(message, new ExchangeImpl(messageExchange), message.getOperation(), true); if (logger.isLoggable(Level.FINE)) { logger.fine("Messager has been sent, we have a response"); } result = createOutMessage(out); if (logger.isLoggable(Level.FINE)) { logger.fine("Out message is " + result); } } catch (MessagingException e) { throw new ClientException(e); } finally { } return result; }
public InOut createInOutExchange() throws MessagingException { InOut exchange = getExchangeFactory().createInOutExchange(); NormalizedMessage in = exchange.createMessage(); exchange.setInMessage(in); return exchange; }
/** * Return a <code>MessageExchangeDecorator</code> for Consumer, as * <code>InOut</code>. * * @see javax.jbi.messaging.MessageExchangeFactory#createInOutExchange() * @return * the message exchange * @throws MessagingException * impossible to create the message exchange */ public InOut createInOutExchange() throws MessagingException { // Create the concrete message exchange MessageExchange meC = this.concreteMef.createInOutExchange(); // Convert into fake message exchange InOut meF = (InOut) Convert. convertConcreteMessageExchangeToFakeMessageExchange(meC, Convert.IN_OUT_PATTERN); ((org.objectweb.petals.tools.rmi.common.serializable. MessageExchange) meF).setRole(meC.getRole()); // Store the messages this.messages.put(meF.getExchangeId(), meC); return meF; }
/** * creates a msg object * * @param qname * the service which will be the receiver * @param inOut * should it be inOut or InOnly * @return the created exchange * @throws MessagingException */ public MessageExchange getNewExchange(QName qname, boolean inOut) throws MessagingException { MessageExchange exchange = null; if (inOut) { exchange = getChannel().createExchangeFactoryForService(qname).createInOutExchange(); } else { exchange = getChannel().createExchangeFactoryForService(qname).createInOnlyExchange(); } return exchange; }
protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException { NormalizedMessage curIn = in; MessageExchange curExchange = exchange; for (int i = 0; i < services.length; i++) { InOut mexchange = this.getDeliveryChannel() .createExchangeFactoryForService(services[i]) .createInOutExchange(); copyProperties(curExchange, mexchange); curIn = invokeService(mexchange, curIn, services[i]); curExchange = mexchange; } getMessageTransformer().transform(exchange, curIn, out); copyProperties(curExchange, exchange); return true; }
/** * Used by POJOs acting as a consumer * @param uri * @param message * @return */ public Future<NormalizedMessage> send(String uri, NormalizedMessage message) { try { InOut me = getExchangeFactory().createInOutExchange(); URIResolver.configureExchange(me, getServiceUnit().getComponent().getComponentContext(), uri); MessageUtil.transferTo(message, me, "in"); final Holder h = new Holder(); getOrCreateCurrentRequest(me).addExchange(me); exchanges.put(me.getExchangeId(), h); BeanEndpoint.this.send(me); return h; } catch (Exception e) { throw new RuntimeException(e); } }
/** * sends the given DOMSource as message to the given service (inOut) * * @param service * the service name to send the message to * @param source * the source to put in the in message content * @return the DOMSource of the out message or null * @throws MessagingException * on any messaging exception */ public MessageExchange sendRawInOutRequest(QName service, Source source) throws MessagingException { InOut inOut = getChannel().createExchangeFactoryForService(service).createInOutExchange(); NormalizedMessage msg = inOut.createMessage(); msg.setContent(source); inOut.setInMessage(msg); if (getChannel().sendSync(inOut)) { return inOut; } else { return null; } }
/** * Creates a new InOut exchange for the given service, interface and/or operation (any of which can be null). */ public InOut createInOutExchange(QName service, QName interfaceName, QName operation) throws MessagingException { DeliveryChannel channel = getDeliveryChannel(); MessageExchangeFactory factory = null; if (service != null) { factory = channel.createExchangeFactoryForService(service); } else if (interfaceName != null) { factory = channel.createExchangeFactory(interfaceName); } else { factory = getExchangeFactory(); } InOut outExchange = factory.createInOutExchange(); if (service != null) { outExchange.setService(service); } if (interfaceName != null) { outExchange.setInterfaceName(interfaceName); } if (operation != null) { outExchange.setOperation(operation); } return outExchange; }
protected void processProviderAsync(MessageExchange exchange) throws Exception { if (exchange.getStatus() == ExchangeStatus.DONE) { String correlationId = (String) exchange.getProperty(correlation); if (correlationId == null) { throw new IllegalStateException(correlation + " property not found"); } // Ack last target hit MessageExchange me = (MessageExchange) store.load(correlationId); done(me); } else if (exchange.getStatus() == ExchangeStatus.ERROR) { String correlationId = (String) exchange.getProperty(correlation); if (correlationId == null) { throw new IllegalStateException(correlation + " property not found"); } // Ack last target hit MessageExchange me = (MessageExchange) store.load(correlationId); done(me); } else if (!(exchange instanceof InOut)) { throw new IllegalStateException("Use an InOut MEP"); } else { MessageExchange me = getExchangeFactory().createInOutExchange(); me.setProperty(correlation, exchange.getExchangeId()); me.setProperty(index, new Integer(0)); targets[0].configureTarget(me, getContext()); store.store(exchange.getExchangeId(), exchange); MessageUtil.transferInToIn(exchange, me); send(me); } }
protected MessageExchange createJbiMessageExchange(Exchange camelExchange, MessageExchangeFactory exchangeFactory, String defaultMep) throws MessagingException, URISyntaxException { // option 1 -- use the MEP that was configured on the endpoint URI ExchangePattern mep = ExchangePattern.fromWsdlUri(defaultMep); if (mep == null) { // option 2 -- use the MEP from the Camel Exchange mep = camelExchange.getPattern(); } MessageExchange answer = null; if (mep != null) { if (mep == ExchangePattern.InOnly) { answer = exchangeFactory.createInOnlyExchange(); } else if (mep == ExchangePattern.InOptionalOut) { answer = exchangeFactory.createInOptionalOutExchange(); } else if (mep == ExchangePattern.InOut) { answer = exchangeFactory.createInOutExchange(); } else if (mep == ExchangePattern.RobustInOnly) { answer = exchangeFactory.createRobustInOnlyExchange(); } else { answer = exchangeFactory.createExchange(new URI(mep.toString())); } } if (getOperation(camelExchange) != null) { answer.setOperation(getOperation(camelExchange)); } return answer; }
/** * sends the given DOMSource as message to the given service (inOut) * * @param service * the service name to send the message to * @param source * the source to put in the in message content * @return the DOMSource of the out message or null * @throws MessagingException * on any messaging exception */ public Source sendRequest(QName service, Source source) throws MessagingException { InOut inOut = getChannel().createExchangeFactoryForService(service).createInOutExchange(); NormalizedMessage msg = inOut.createMessage(); msg.setContent(source); inOut.setInMessage(msg); if (getChannel().sendSync(inOut)) { try { Source result = sourceTransformer.toDOMSource(inOut.getOutMessage().getContent()); done(inOut); return result; } catch (Exception ex) { ex.printStackTrace(); return null; } } else { return null; } }
/** * Creates a new InOut exchange for the given service, interface and/or operation (any of which can be null). */ public InOut createInOutExchange(QName service, QName interfaceName, QName operation) throws MessagingException { MessageExchangeFactory factory = null; if (service != null) { factory = getDeliveryChannel().createExchangeFactoryForService(service); } else if (interfaceName != null) { factory = getDeliveryChannel().createExchangeFactory(interfaceName); } else { factory = getExchangeFactory(); } InOut outExchange = factory.createInOutExchange(); if (service != null) { outExchange.setService(service); } if (interfaceName != null) { outExchange.setInterfaceName(interfaceName); } if (operation != null) { outExchange.setOperation(operation); } return outExchange; }
InOut me = getExchangeFactory().createInOutExchange(); targets[i].configureTarget(me, getContext()); if (i == 0) {
MessageExchange tme = getExchangeFactory().createInOutExchange(); transformer.configureTarget(tme, getContext());
InOut tme = getExchangeFactory().createInOutExchange(); transformer.configureTarget(tme, getContext());
InOut enricherTargetME = getExchangeFactory().createInOutExchange(); enricherTarget.configureTarget(enricherTargetME, getContext());
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Skip done exchanges if (exchange.getStatus() == ExchangeStatus.DONE) { return; // Handle error exchanges } else if (exchange.getStatus() == ExchangeStatus.ERROR) { return; } // lets create an endpoint DeliveryChannel deliveryChannel = getDeliveryChannel(); MessageExchangeFactory rpcFactory = deliveryChannel.createExchangeFactory(requestResponseEndpoint); InOut rpc = rpcFactory.createInOutExchange(); rpc.setInMessage(exchange.getMessage("in")); boolean answer = deliveryChannel.sendSync(rpc); MessageExchangeFactory outputFactory = deliveryChannel.createExchangeFactory(outputEndpoint); InOnly inOnly = outputFactory.createInOnlyExchange(); if (answer) { inOnly.setInMessage(rpc.getOutMessage()); deliveryChannel.send(inOnly); done(exchange); } else if (!(exchange instanceof InOnly)) { inOnly.setError(rpc.getError()); Fault fault = rpc.getFault(); fail(exchange, fault); } else { // terminate the exchange done(exchange); } done(rpc); }