J
Jonathan Bartlett
I'm having trouble serializing inner classes. Here's the issue, and
perhaps you can even find a better way to do this architecturally.
Basically, the goal is to have objects which, when certain methods are
called, send JMS messages to a message processor. I think it would be
easiest to have both sides of the messages in the class file, so for
example, the message processor would look for an interface called
ActionMessage, with a single function process(). The general form would be
while there are messages to be processed
get next message
call process() on that message
The main classes themselves would look like this:
public interface ActionMessage extends Serializable {
public void process();
}
public class WhateverClass {
public void doSomething() {
//do something local here
//Setup q connection
ActionMessage am =
new ActionMessage() {
public void process() {
//do something remote here
}
};
//note -- session is a QueueSession
ObjectMessage msg = session.createObjectMessage();
msg.setObject(am);
sender.send(msg)
}
This always throws a exception saying "Object cannot be serialized".
Any ideas? So far I've been testing it even with a completely empty
ActionMessage and it still fails.
If anyone has a better idea of how to accomplish this in general, it
would also be appreciated.
Jon
perhaps you can even find a better way to do this architecturally.
Basically, the goal is to have objects which, when certain methods are
called, send JMS messages to a message processor. I think it would be
easiest to have both sides of the messages in the class file, so for
example, the message processor would look for an interface called
ActionMessage, with a single function process(). The general form would be
while there are messages to be processed
get next message
call process() on that message
The main classes themselves would look like this:
public interface ActionMessage extends Serializable {
public void process();
}
public class WhateverClass {
public void doSomething() {
//do something local here
//Setup q connection
ActionMessage am =
new ActionMessage() {
public void process() {
//do something remote here
}
};
//note -- session is a QueueSession
ObjectMessage msg = session.createObjectMessage();
msg.setObject(am);
sender.send(msg)
}
This always throws a exception saying "Object cannot be serialized".
Any ideas? So far I've been testing it even with a completely empty
ActionMessage and it still fails.
If anyone has a better idea of how to accomplish this in general, it
would also be appreciated.
Jon