Hi,
I'm trying to, instead of using messaging-config.xml, create
the destination through the Java code, so that the users can
dynamically subscribe to the newly created destinations.
Here is my Java code:
public void createDest() {
MessageBroker msgBroker =
MessageBroker.getMessageBroker(null);
MessageService service = (MessageService)
msgBroker.getService("message-service");
MessageDestination d =
(MessageDestination)service.createDestination("test");
NetworkSettings ns = new NetworkSettings();
ns.setSubscriptionTimeoutMinutes(30);
ns.setSharedBackend(true);
d.setNetworkSettings(ns);
d.addChannel("my-polling-amf");
d.start();
The following method is called in actionscript once the
creationComplete is triggered:
private function run() {
i.createDest();
var consumer:Consumer = new Consumer();
consumer.destination = "test";
consumer.addEventListener(MessageEvent.MESSAGE,
messageHandler2);
consumer.subscribe();
}
The first line calls the method which creates the
destination. It is really created and started (its isValid() and
isStarted() methods return true)
However when I run the code I encounter the following error
(which points to the "consumer.subscribe();" line):
[MessagingError message='Destination 'test' either does not
exist or the destination has no channels defined (and the
application does not define any default channels.)']
None of the items the error message is complaining about are
true. Destination 'test' does exist, it has a channel (shown in the
Java code) and also in the messaging-config.xml a default channel
is defined:
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
It also should be mentioned if I change the "test" to any
destination that is explicitly defined in the messaging-config.xml
it would work. (Instead of actionscript I also tried doing the same
thing in mxml to no avail).
I would appreciate any help to resolve this issue.