@Override public boolean isActive() { return ExchangeStatus.ACTIVE.equals(this.status); }
@Override public boolean isError() { return ExchangeStatus.ERROR.equals(this.status); }
@Override public boolean isDone() { return ExchangeStatus.DONE.equals(this.status); }
private static Status toStatus(final ExchangeStatus status) { if (ExchangeStatus.ACTIVE.equals(status)) { return Status.ACTIVE; } else if (ExchangeStatus.DONE.equals(status)) { return Status.DONE; } else if (ExchangeStatus.ERROR.equals(status)) { return Status.ERROR; } else { throw new IllegalArgumentException("unknown status"); } }
/** * Depending on the state of the Exchange, clean IN and/or OUT normalized * messages to reduce exchange size. Status DONE, ERROR : all messages are * cleared Fault message : all other messages are cleared OUT message set : * IN message is cleared */ public void cleanMessages() { // if status is DONE or ERROR, do not send // Normalized messages if (!ExchangeStatus.ACTIVE.equals(status)) { messages.clear(); fault = null; } // if there is a fault, no other messages are kept if (fault != null) { messages.clear(); } // if OUT response, IN msg is not kept if (messages.containsKey(OUT_MSG) && messages.containsKey(IN_MSG)) { messages.remove(IN_MSG); } }
/** * Retrieve the right {@code OnJBIResponseTransformation} for the the given InOnly JBI exchange. * * @param jbiExchange * The JBI Exchange * @param onJBIResponseTransformation * A holder in which the right {@code OnJBIResponseTransformation} will be put * @throws OnJBIResponseTransformationException * Unexpected case that should not occur, or system error */ private void lookForJBITransformationAsInOnly(final Exchange jbiExchange, final Holder<OnJBIResponseTransformation> onJBIResponseTransformation) throws OnJBIResponseTransformationException { final ExchangeStatus status = jbiExchange.getStatus(); if (status.equals(ExchangeStatus.DONE)) { onJBIResponseTransformation.value = this.lookForJBIOutTransformation(null); } else if (status.equals(ExchangeStatus.ERROR)) { onJBIResponseTransformation.value = this.lookForJBIErrorTransformation(null); } else { throw new OnJBIResponseTransformationException( String.format("Invalid JBI response status for the MEP InOnly (status: %s)", status), HttpStatus.INTERNAL_SERVER_ERROR_500); } }
/** * @see MessageExchangeImpl#writeObject(ObjectOutputStream) */ protected void writeObjectDelegate(ObjectOutputStream s) throws IOException { // Role serialization if (MessageExchange.Role.CONSUMER.equals(role)) { s.writeShort(SERIALIZE_ROLE_CONSUMER); } else { s.writeShort(SERIALIZE_ROLE_PROVIDER); } // Status serialization if (ExchangeStatus.ACTIVE.equals(status)) { s.writeShort(SERIALIZE_STATUS_ACTIVE); } else if (ExchangeStatus.DONE.equals(status)) { s.writeShort(SERIALIZE_STATUS_DONE); } else { s.writeShort(SERIALIZE_STATUS_ERROR); } s.defaultWriteObject(); }
/** * Used to serialize Status and Role objects * * @param s * @throws IOException */ private void writeObject(final ObjectOutputStream s) throws IOException { // Role serialization if (isConsumer()) { s.writeShort(SERIALIZE_ROLE_CONSUMER); } else { s.writeShort(SERIALIZE_ROLE_PROVIDER); } // Status serialization if (ExchangeStatus.ACTIVE.equals(this.status)) { s.writeShort(SERIALIZE_STATUS_ACTIVE); } else if (ExchangeStatus.DONE.equals(this.status)) { s.writeShort(SERIALIZE_STATUS_DONE); } else { s.writeShort(SERIALIZE_STATUS_ERROR); } s.defaultWriteObject(); } }
public static TransportedMessage updateTransportedExchange(final @Nullable TransportedMessage m, final ServiceKey service, final MessageExchange exchange) { final TransportedMessage msg; if (ExchangeStatus.ACTIVE.equals(exchange.getStatus())) { if (m == null) { msg = TransportedMessage.newMessage(service, exchange); } else { // we will be expecting an answer msg = TransportedMessage.middleMessage(m, exchange); } } else { assert m != null; msg = TransportedMessage.lastMessage(m, exchange); } return msg; }
if (status.equals(ExchangeStatus.DONE)) { onJBIResponseTransformation.value = this.lookForJBIOutTransformation(null); } else if (status.equals(ExchangeStatus.ERROR)) { onJBIResponseTransformation.value = this.lookForJBIErrorTransformation(null); } else if (status.equals(ExchangeStatus.ACTIVE)) { final Fault fault = jbiExchange.getFault(); if (fault != null) {
/** * @see MessageExchangeImpl#writeObject(ObjectOutputStream). * @param s * the object output stream * @throws IOException * impossible to write object delegate * */ protected void writeObjectDelegate(final ObjectOutputStream s) throws IOException { // Role serialization if (MessageExchange.Role.CONSUMER.equals(this.role)) { s.writeShort(MessageExchange.SERIALIZE_ROLE_CONSUMER); } else { s.writeShort(MessageExchange.SERIALIZE_ROLE_PROVIDER); } // Status serialization if (ExchangeStatus.ACTIVE.equals(this.status)) { s.writeShort(MessageExchange.SERIALIZE_STATUS_ACTIVE); } else if (ExchangeStatus.DONE.equals(this.status)) { s.writeShort(MessageExchange.SERIALIZE_STATUS_DONE); } else { s.writeShort(MessageExchange.SERIALIZE_STATUS_ERROR); } s.defaultWriteObject(); }
/** * (non-Javadoc) * * @see javax.jbi.messaging.MessageExchange#setFault(javax.jbi.messaging.Fault) */ public void setFault(Fault fault) throws MessagingException { checkNotTerminated(); if (role == null) { throw new MessagingException("The Role is not defined."); } // check that a fault has not already been sent if (this.fault != null) { throw new MessagingException("A fault has already been set."); } // check that the status has not be positionned with DONEor EXCEPTION if (ExchangeStatus.DONE.equals(status) || ExchangeStatus.ERROR.equals(status)) { throw new MessagingException( "The MessageExchange state and the current Role do not allow this operation."); } // only the provider can send a fault, except in the case of a // InOptionnalOut, // where the consumer can set a fault after the provider sent a response if (MessageExchange.Role.CONSUMER.equals(role) && !messages.containsKey(OUT_MSG)) { throw new MessagingException( "The MessageExchange state and the current Role do not allow this operation."); } this.fault = fault; }
if (ExchangeStatus.DONE.equals(status)) { if (Role.CONSUMER.equals(role)) { if (IN_ONLY_PATTERN.equals(pattern)) {
/** * Set the properties to the message exchange to specify that a synchronious * response is expected * * @param exchange * * @throws MessagingException * The <code>sync_send()</code> is forbidden for * acknowledgment send */ public static void setSendSyncProperties(MessageExchangeImpl exchange) throws MessagingException { if (!exchange.getStatus().equals(ExchangeStatus.ACTIVE)) { throw new MessagingException( "Synchronious send is forbidden when sending an acknowledgement"); } // specify the role of the requester of the sync exchange, used // internally if (MessageExchange.Role.PROVIDER.equals(exchange.getRole())) exchange.setProperty(PROPERTY_SENDSYNC_CONSUMER, "true"); else exchange.setProperty(PROPERTY_SENDSYNC_PROVIDER, "true"); // set the property as defined in the JBI specifications exchange.setProperty(DeliveryChannelImpl.PROPERTY_SENDSYNC, "true"); }
if (!ExchangeStatus.ACTIVE.equals(exchangeImpl.getStatus())) { exchangeImpl.setTerminated(true);
if (ExchangeStatus.DONE.equals(status)) { if (isConsumer()) {