I assume the Schedule object is Serializable. The enhance/strip logic in that other post assumes a String payload.
You can simply wrap your Schedule object in a wrapper...
Code:
@SuppressWarnings("serial")
public class Wrapper implements Serializable {
private final Schedule schedule;
private final String command;
public Wrapper(Schedule schedule, String command) {
this.schedule = schedule;
this.command = command;
}
public Schedule getSchedule() {
return this.schedule.
}
public String getCommand() {
return command;
}
}
Then, on the outbound side, right before the tcp outbound endpoint, add a transformer
Code:
<transformer input-channel="input" output-channel="toTcp"
expression="new foo.Wrapper(payload, 'CREATE')"/>
and on the inbound side, right after the TCP inbound...
Code:
<chain input-channel="fromTCP" output-channel="toHeaderRouter">
<header-enricher>
<header name="COMMAND" expression="payload.command"/>
</header-enricher>
<transformer expression="payload.schedule"/>
</chain>
This all assumes you're TCP connection factories are configured to use the Java serialization (de)serializers...
Code:
<bean id="defaultSerializer" class="org.springframework.core.serializer.DefaultSerializer" />
<bean id="defaultDeserializer" class="org.springframework.core.serializer.DefaultDeserializer" />