How to send Context Information from service bean to message composer in FSW 6?

Solution In Progress - Updated -


For a new Switchyard service exposed by http binding, we need to set some context information within a service bean, and retrieve that information in the message composer before sending the response.

We are able to set the context information for the incoming message in a custom Http message composer:

public class BaseHttpComposer extends BaseMessageComposer<HttpBindingData> {

    public Message compose(HttpBindingData httpBindingData, Exchange exchange)
            throws Exception {
        HttpRequestBindingData request = (HttpRequestBindingData) httpBindingData;
        String body = request.getBodyAsString();
        Message m = exchange.createMessage();
        System.out.println("BaseHttpComposer.compose()-> set myFlag = 1");
        m.getContext().setProperty("myFlag", "1");      
        return m;

This context property is available in the bean implementation:

    public String process(String content) throws Exception {
        Message message  = exchange.getMessage();
        String myflag = message.getContext().getPropertyValue("myFlag").toString()
                return "InnerBean.process() -> myFlag = " + myflag;

However, in the decompose method of the custom http message composer, the property is missing:

    public HttpBindingData decompose(Exchange exchange, HttpBindingData httpBindingData)
            throws Exception {
        String body = (String) exchange.getMessage().getContent().toString();
        String myFlag = (String) exchange.getMessage().getContext().getPropertyValue("myFlag");  // <-- context property is NULL here!?
        System.out.println("BaseHttpComposer.decompose() -> myFlag = " + myFlag);

        HttpResponseBindingData response = (HttpResponseBindingData) httpBindingData;
        /* response manipulation */
        return response;


  • Red Hat JBoss Fuse Service Works
    • 6.0.0
  • Red Hat JBoss Fuse
    • 6.2.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content