public InOnly createInOnlyExchange() throws MessagingException { InOnly exchange = getExchangeFactory().createInOnlyExchange(); NormalizedMessage in = exchange.createMessage(); exchange.setInMessage(in); return exchange; }
public InOnly createInOnlyExchange() throws MessagingException { InOnly exchange = getExchangeFactory().createInOnlyExchange(); NormalizedMessage in = exchange.createMessage(); exchange.setInMessage(in); return exchange; }
protected void processFile(File file) throws Exception { InputStream stream = new BufferedInputStream(new FileInputStream(file)); InOnly exchange = getExchangeFactory().createInOnlyExchange(); configureExchangeTarget(exchange); NormalizedMessage message = exchange.createMessage(); exchange.setInMessage(message); marshaler.readMessage(exchange, message, stream, file.getCanonicalPath()); // sending the file itself along as a message property and holding on to // the stream we opened exchange.getInMessage().setProperty(FileComponent.FILE_PROPERTY, file); this.openExchanges.put(exchange.getExchangeId(), stream); send(exchange); }
protected void forwardToExchange(MessageExchange exchange, InOnly outExchange, NormalizedMessage in) throws MessagingException { NormalizedMessage out = outExchange.createMessage(); outExchange.setInMessage(out); getMessageTransformer().transform(exchange, in, out); getDeliveryChannel().send(outExchange); }
protected void forwardToExchange(MessageExchange exchange, InOnly outExchange, NormalizedMessage in) throws MessagingException { NormalizedMessage out = outExchange.createMessage(); outExchange.setInMessage(out); getMessageTransformer().transform(exchange, in, out); getDeliveryChannel().send(outExchange); } }
public void sendMessages(int messageCount, boolean sync) throws MessagingException { LOGGER.info("Looking for services for interface: {}", interfaceName); ServiceEndpoint[] endpoints = context.getEndpointsForService(interfaceName); if (endpoints.length > 0) { ServiceEndpoint endpoint = endpoints[0]; LOGGER.info("Sending to endpoint: {}", endpoint); for (int i = 0; i < messageCount; i++) { InOnly exchange = context.getDeliveryChannel().createExchangeFactory().createInOnlyExchange(); NormalizedMessage message = exchange.createMessage(); exchange.setEndpoint(endpoint); exchange.setInMessage(message); // lets set the XML as a byte[], String or DOM etc String xml = "<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>" + " <s12:Body><foo>Hello!</foo> </s12:Body>" + "</s12:Envelope>"; message.setContent(new StringSource(xml)); LOGGER.info("sending message: {}", i); DeliveryChannel deliveryChannel = context.getDeliveryChannel(); LOGGER.info("sync send on deliverychannel: {}", deliveryChannel); if (sync) { deliveryChannel.sendSync(exchange); } else { deliveryChannel.send(exchange); } } } else { LOGGER.warn("No endpoints available for interface: {}", interfaceName); } }
/** * Sends the message to the bus * @param pdu the trap received */ private void sendSnmpTrapMessage(PDU pdu) { try { // create an inOnly exchange InOnly io = getExchangeFactory().createInOnlyExchange(); // configure the exchange target configureExchangeTarget(io); // create the in message NormalizedMessage inMsg = io.createMessage(); // now let the marshaler convert the snmp data into // a normalized message to send to jbi bus this.marshaler.convertToJBI(io, inMsg, null, pdu); // put the in message into the inOnly exchange io.setInMessage(inMsg); // send the exchange getChannel().send(io); } catch (MessagingException ex) { logger.error("Error while trying to send the snmp trap PDU to the jbi bus", ex); } }
/** * sends the message to the bus * * @param request the request PDU * @param response the response PDU */ private void sendSnmpDataMessage(PDU request, PDU response) { try { // create a inOnly exchange InOnly io = getExchangeFactory().createInOnlyExchange(); // configure the exchange target configureExchangeTarget(io); // create the in message NormalizedMessage inMsg = io.createMessage(); // now let the marshaller convert the snmp data into a normalized // message to send to jbi bus this.marshaler.convertToJBI(io, inMsg, request, response); // then put the in message into the inOnly exchange io.setInMessage(inMsg); // and use send to deliver it getChannel().send(io); } catch (MessagingException ex) { logger.error("Error while trying to send the snmp event to the jbi bus", ex); } }
NormalizedMessage in = me.createMessage(); getMessageTransformer().transform(me, exchange.getInMessage(), in); me.setInMessage(in); me.setEndpoint(endpoint); Set names = exchange.getPropertyNames();
protected void processFile(FTPClient ftp, String file) throws Exception { InputStream in = ftp.retrieveFileStream(file); InOnly exchange = getExchangeFactory().createInOnlyExchange(); configureExchangeTarget(exchange); NormalizedMessage message = exchange.createMessage(); exchange.setInMessage(message); if (getTargetOperation() != null) { exchange.setOperation(getTargetOperation()); } marshaler.readMessage(exchange, message, in, file); if (stateless) { exchange.setProperty(FtpData.class.getName(), new FtpData(file, ftp, in)); } else { this.openExchanges.put(exchange.getExchangeId(), new FtpData(file, ftp, in)); } send(exchange); }
/** * sends the given DOMSource as message to the given service (inOnly) * * @param service * the service name to send the message to * @param source * the source to put in the in message content * @return true on sucessful delivering or false on failure * @throws MessagingException * on any messaging exception */ public boolean sendMessage(QName service, Source source) throws MessagingException { InOnly inOnly = getChannel().createExchangeFactoryForService(service).createInOnlyExchange(); NormalizedMessage msg = inOnly.createMessage(); msg.setContent(source); inOnly.setInMessage(msg); if (getChannel().sendSync(inOnly)) { return inOnly.getStatus() == ExchangeStatus.DONE; } else { return false; } }
protected void sendAggregate(String processCorrelationId, String correlationId, Object aggregation, boolean timeout, boolean sync) throws Exception { InOnly me = getExchangeFactory().createInOnlyExchange(); if (processCorrelationId != null) { me.setProperty(JbiConstants.CORRELATION_ID, processCorrelationId); } me.setProperty(getService().toString() + ":" + getEndpoint() + ":correlation", correlationId); target.configureTarget(me, getContext()); NormalizedMessage nm = me.createMessage(); me.setInMessage(nm); buildAggregate(aggregation, nm, me, timeout); closeAggregation(correlationId); if (sync) { sendSync(me); } else { send(me); } }
NormalizedMessage nmsg = inonly.createMessage(); mapper.toNMS(nmsg, odeMex.getRequest(), odeMex.getOperation().getInput().getMessage(), null); inonly.setInMessage(nmsg); copyMexProperties(jbiMex, odeMex); _ode._scheduler.registerSynchronizer(new Scheduler.Synchronizer() {
public void sendMessages(int messageCount, boolean sync) throws JBIException { ComponentContext context = getContext(); for (int i = 0; i < messageCount; i++) { InOnly exchange = context.getDeliveryChannel().createExchangeFactory().createInOnlyExchange(); NormalizedMessage msg = exchange.createMessage(); ServiceEndpoint destination = null; if (resolver != null) { destination = resolver.resolveEndpoint(getContext(), exchange, NullEndpointFilter.getInstance()); } if (destination != null) { // lets explicitly specify the destination - otherwise // we'll let the container choose for us exchange.setEndpoint(destination); } exchange.setInMessage(msg); // lets set the XML as a byte[], String or DOM etc msg.setContent(new StringSource(this.message)); if (sync) { boolean result = context.getDeliveryChannel().sendSync(exchange, 1000); if (!result) { throw new MessagingException("Message delivery using sendSync has timed out"); } } else { context.getDeliveryChannel().send(exchange); } } }
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); }