Hi Allard,
I am using axon with Distributed command bus which uses Jgroups for clustering and reliable messaging. I am fetching logs from Jgroups but i was only getting the message byte size in the logs where i wanted to get the actual message which is being sent from the channel so i found one solution for that which is to write own protocol and marshall/unmarshall the object to get the actual message string contents. This is the url of that mail chain,
Jgroups actual message content Logging
According to the documentation i have to set a Receiver while sending the message on to the channel ::
Jgroups writing custom protocol
So i set a custom receiver so that my class will be referred and the logging logic can be triggered using ::
JChannel channel;
channel.setReceiver(new ReceiverAdapter() {
public void receive(Message msg) {
LogMessage.ExampleHeader hdr = (LogMessage.ExampleHeader) msg.getHeader((short) 1900);
System.out.println("-- received " + msg + ", header is " + hdr);
}
});
and registering the class via ::
ClassConfigurator.add((short)1900, LogMessage.ExampleHeader.class);
where LogMessage is custom class extending protocol.
I am getting the following exception ::
java.lang.IllegalArgumentException: The given channel already has a receiver configured. Has the channel been reused with other Connectors?
I can see that axon is checking that any receiver is already registered or null in the JGroupsConnector class and then throwing an illegal argument exception ::
Assert.isTrue(channel.getReceiver() == null || channel.getReceiver() == messageReceiver,
"The given channel already has a receiver configured. "
- “Has the channel been reused with other Connectors?”);
and this class has its own inner class as Reciever ::
private class MessageReceiver extends ReceiverAdapter
so it is throwing the exception as we have already set a receiver , Is there any way if we can set our own receiver so that custom logic can be triggered ?