Example #1
0
  protected void invokeInboundChain(Exchange ex, Endpoint ep) {
    Message m = getInBoundMessage(ex);
    Message inMsg = ep.getBinding().createMessage();
    MessageImpl.copyContent(m, inMsg);

    // Copy Response Context to Client inBound Message
    // TODO a Context Filter Strategy required.
    inMsg.putAll(m);

    inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
    inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
    inMsg.setExchange(ex);

    Exception exc = inMsg.getContent(Exception.class);
    if (exc != null) {
      ex.setInFaultMessage(inMsg);
      ColocInFaultObserver observer = new ColocInFaultObserver(bus);
      observer.onMessage(inMsg);
    } else {
      // Handle Response
      ex.setInMessage(inMsg);
      PhaseManager pm = bus.getExtension(PhaseManager.class);
      SortedSet<Phase> phases = new TreeSet<Phase>(pm.getInPhases());
      ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE);

      InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
      inMsg.setInterceptorChain(chain);
      chain.doIntercept(inMsg);
    }
    ex.put(ClientImpl.FINISHED, Boolean.TRUE);
  }
Example #2
0
    @Override
    public void close(Message message) throws IOException {
      if (Boolean.TRUE.equals(message.getExchange().get(LocalConduit.DIRECT_DISPATCH))) {
        final Exchange exchange = (Exchange) message.getExchange().get(LocalConduit.IN_EXCHANGE);

        MessageImpl copy = new MessageImpl();
        copy.putAll(message);
        MessageImpl.copyContent(message, copy);
        CachedOutputStream stream = (CachedOutputStream) message.getContent(OutputStream.class);
        copy.setContent(InputStream.class, stream.getInputStream());
        if (exchange != null && exchange.getInMessage() == null) {
          exchange.setInMessage(copy);
        }
        conduit.getMessageObserver().onMessage(copy);
        return;
      }

      super.close(message);
    }
  @Override
  public void onMessage(byte[] message, ZMQ.Socket zmqSocket) {
    getLogger().log(Level.FINE, "server received request: ", message);

    Message inMessage = new MessageImpl();
    inMessage.setContent(InputStream.class, new ByteArrayInputStream(message));
    ((MessageImpl) inMessage).setDestination(this);
    inMessage.put("socket", zmqSocket);

    incomingObserver.onMessage(inMessage);
  }
Example #4
0
  public void process(Exchange camelExchange) throws Exception {
    LOG.trace("Received request : {}", camelExchange);

    org.apache.cxf.message.Message cxfMessage =
        endpoint
            .getCxfBeanBinding()
            .createCxfMessageFromCamelExchange(camelExchange, endpoint.getHeaderFilterStrategy());

    cxfMessage.put(CamelTransportConstants.CAMEL_EXCHANGE, camelExchange);
    ((MessageImpl) cxfMessage).setDestination(this);

    // Handling the incoming message
    // The response message will be send back by the outgoing chain
    incomingObserver.onMessage(cxfMessage);
  }