/** * Check if this request is completely finished. * * @return <code>true</code> if both the Exchange is DONE and there are no more outstanding sent exchanges */ public boolean isFinished() { for (MessageExchange exchange : exchanges) { if (ExchangeStatus.ACTIVE.equals(exchange.getStatus())) { return false; } } return true; }
/** * Check and storage the concrete message exchange if it is not active. * @param fake * the fake message exchange * @param concrete * the concrete message exchange */ public void checkAndStorageMessageExchange( final MessageExchange fake, final MessageExchange concrete) { if (concrete.getStatus() == javax.jbi.messaging. ExchangeStatus.ACTIVE) { this.messages.put(fake.getExchangeId(), concrete); } }
private void checkEndOfRequest(MessageExchange me) throws MessagingException { if (!ExchangeStatus.ACTIVE.equals(me.getStatus())) { Request request = getRequest(me); if (request != null) { checkEndOfRequest(request); } } }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { if (exchange.getStatus() == ExchangeStatus.ACTIVE) { try { NormalizedMessage message = getInMessage(exchange); process(exchange, message); } catch (Exception e) { LOGGER.debug("Exchange failed", e); fail(exchange, e); } } }
private void doSend(MessageExchange exchange) throws MessagingException { boolean txSync = exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync && ExchangeStatus.ACTIVE.equals(exchange.getStatus())) { sendSync(exchange); } else { send(exchange); } }
@Override protected void processAsync(MessageExchange exchange) throws Exception { validateMessageExchange(exchange); if (exchange.getStatus() == ExchangeStatus.DONE) { return; } else if (exchange.getStatus() == ExchangeStatus.ERROR) { return; } else if (exchange.getFault() != null) { done(exchange); return; } processMessage(exchange); done(exchange); }
@Override public void process(MessageExchange exchange) throws Exception { if (exchange.getRole() == Role.PROVIDER) { if (exchange.getStatus() == ExchangeStatus.ACTIVE) { //TODO: actually implement some control bus operations fail(exchange, new UnsupportedOperationException("No control bus operations available")); } } else { throw new MessagingException( "Unexpected exchange role: CamelContextEndpoint is not capable of handling " + exchange.getRole()); } }
private void handleLateResponse(MessageExchange exchange) throws Exception { // if the exchange is no longer active by now, something else probably went wrong in the meanwhile logger.warn(LateResponseException.createMessage(exchange)); if (exchange.getStatus() == ExchangeStatus.ACTIVE) { if (lateResponseStrategy == LateResponseStrategy.error) { // ends the exchange in ERROR fail(exchange, new LateResponseException(exchange)); } else { // let's log the exception message text, but end the exchange with DONE done(exchange); } } }
protected void handleLateResponse(MessageExchange exchange) throws Exception { // if the exchange is no longer active by now, something else probably went wrong in the meanwhile if (exchange.getStatus() == ExchangeStatus.ACTIVE) { if (lateResponseStrategy == LateResponseStrategy.error) { // ends the exchange in ERROR fail(exchange, new LateResponseException(exchange)); } else { // let's log the exception message text, but end the exchange with DONE logger.warn(LateResponseException.createMessage(exchange)); done(exchange); } } }
protected void handleException(SmxHttpExchange httpExchange, MessageExchange exchange, Throwable ex) { try { marshaler.handleException(exchange, httpExchange, ex); boolean txSync = exchange.getStatus() == ExchangeStatus.ACTIVE && exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync) { sendSync(exchange); } else { send(exchange); } } catch (Exception e) { logger.warn("Unable to send back exchange in error", e); } }
protected ClientException createFromOutMessage(MessageExchange messageExchange) { ClientException result = null; String message = null; if (ExchangeStatus.ERROR.equals(messageExchange.getStatus())) { message = "Got an ERROR while trying to send message to service, cause : TODO serialize ERROR"; result = new ClientException(message); } else if (messageExchange.getFault() != null) { message = "Got a FAULT while invoking service, cause : TODO serialize Fault"; // TODO : Create Document from Fault result = new ClientException(message); } else { message = "Got something wrong while invoking service..."; result = new ClientException(message); } return result; }
protected NormalizedMessage extract(MessageExchange me) throws ExecutionException { if (me.getStatus() == ExchangeStatus.ERROR) { throw new ExecutionException(me.getError()); } else if (me.getFault() != null) { throw new ExecutionException(new FaultException("Fault occured", me, me.getFault())); } else { return me.getMessage("out"); } } }
public void process(MessageExchange exchange) throws Exception { boolean txSync = exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync && exchange.getRole() == Role.PROVIDER && exchange.getStatus() == ExchangeStatus.ACTIVE) { processSync(exchange); } else { processAsync(exchange); } }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Handle consumer exchanges && non-active RobustInOnly provider exchanges if (exchange.getRole() == MessageExchange.Role.CONSUMER || exchange.getProperty(correlation) != null) { processOngoingExchange(exchange); } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) { processFirstExchange(exchange); } }
public void send(MessageExchange exchange) throws MessagingException { prepareExchange(exchange); handleExchange(exchange, exchange.getStatus() == ExchangeStatus.ACTIVE); try { channel.send(exchange); } catch (MessagingException e) { handleExchange(exchange, false); throw e; } }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Handle consumer exchanges && non-active RobustInOnly provider exchanges if (exchange.getRole() == MessageExchange.Role.CONSUMER || exchange.getProperty(correlation) != null) { processOngoingExchange(exchange); } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) { processFirstExchange(exchange); } }
public void process(MessageExchange exchange) throws Exception { if (exchange.getStatus() == ExchangeStatus.ACTIVE) { NormalizedMessage nm = exchange.getMessage("in"); if (nm == null) { throw new IllegalStateException("Exchange has no input message"); } SmxHttpExchange httpEx = new Exchange(exchange); try { marshaler.createRequest(exchange, nm, httpEx); jettyClient.send(httpEx); } catch (Exception e){ handleException(httpEx, exchange, e); } } }
protected void onExchangeAccepted(ExchangeEvent event) { MessageExchange me = event.getExchange(); // This is a new exchange sent by a consumer if (me.getStatus() == ExchangeStatus.ACTIVE && me.getRole() == Role.PROVIDER && me.getMessage("out") == null && me.getFault() == null && me instanceof MessageExchangeImpl) { String source = EndpointSupport.getUniqueKey(me.getEndpoint()); EndpointStats stats = endpointStats.get(source); if (stats != null) { stats.incrementInbound(); } } }
public void handleMessage(Message message) throws Fault { MessageExchange exchange = message .getContent(MessageExchange.class); try { if (message.get("needSetDone") != null && message.get("needSetDone").equals(Boolean.TRUE) && exchange.getStatus() == ExchangeStatus.ACTIVE) { exchange.setStatus(ExchangeStatus.DONE); message.getExchange().get(ComponentContext.class) .getDeliveryChannel().send(exchange); } } catch (Exception e) { throw new Fault(e); } }
protected void assertExchangeWorked(MessageExchange me) throws Exception { if (me.getStatus() == ExchangeStatus.ERROR) { if (me.getError() != null) { throw me.getError(); } else { fail("Received ERROR status"); } } else if (me.getFault() != null) { fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent())); } }