Hi
according to Chapter 3 of the Granite reference doc - 'When using a services-config.xml file, it's necessary to use the compiler option -services path/to/services-config.xml so the Flex SDK itself can handle the creation of the channel and other remoting objects. If you don't use this option, you will have to specify manually a channel and endpoint for each destination in ActionScript 3 :
private function init():void {
srv = new RemoteObject("myService");
srv.source = "myService";
srv.channelSet = new ChannelSet();
srv.channelSet.addChannel(new AMFChannel("graniteamf",
"http://{
server.name}:{server.port}/myapp/graniteamf/amf"));
srv.showBusyCursor = true;
}'
I am trying to do this for a Gravity Channel as below, but cannot seem to get it to work .
private function init():void {
srv = new RemoteObject("myService");
srv.source = "myService";
srv.destination="GravityService";
srv.channelSet = new ChannelSet();
srv.channelSet.addChannel(new GravityChannel("gravityamf",
"http://{
server.name}:{server.port}/myapp/gravityamf/amf"));
I am then trying to create a Consumer as follows:
var consumer : Consumer = new Consumer();
consumer.destination = "GravityService";
consumer.subscribe();
But when I do so I get the following error:
MessagingError message='Destination 'GravityService' either does not exist or the destination has no channels defined (and the application does not define any default channels.)'
When I add in the additional compiler option -services path/to/services-config.xml, my Consumer subscribes without problem and Gravity works fine.
I am able to create AMF services programmatically without problem using almost identical code (by adding an AMFChannel rather than a GravityChannel). Can someone please tell me what I'm doing wrong.
Thanks in advance!
Here are the relevant bits from my services-config.xml file :
<channel-definition
id="gravityamf"
class="org.granite.gravity.channels.GravityChannel">
<endpoint
uri="
http://myServer:8080/myapp/gravityamf/amf"
class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
<services>
<service id="messaging-service"
class="flex.messaging.services.MessagingService"
messageTypes="flex.messaging.messages.AsyncMessage">
<adapters>
<adapter-definition id="jms"
class="org.granite.gravity.adapters.JMSServiceAdapter" default="true"/>
</adapters>
<destination id="GravityService">
<channels>
<channel ref="gravityamf"/>
</channels>
<properties>
<jms>
<destination-type>Topic</destination-type>
<message-type>javax.jms.TextMessage</message-type>
<connection-factory>ConnectionFactory</connection-factory>
<destination-jndi-name>topic/GravityTopic</destination-jndi-name>
<destination-name>GravityTopic</destination-name>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<transacted-sessions>false</transacted-sessions>
</jms>
</properties>
<adapter ref="jms" />
</destination>
</service>
</services>