How to incorporate Consumer functionatliy into Cairngorm?

Posted on 2009-02-10
Medium Priority
Last Modified: 2013-11-11

I'm converting a Flex application to Cairngorm and haven't been able to figure out what to do with the Consumer calls.  I've read through all the documentation and included CairngormEnterprise.swc into my build and added the Consumer instance to my ServiceLocator just as with any other http or RPC call.  The error I keep on getting is this:

Only one ServiceLocator instance can be instantiated

I'm guessing this is because I'm instantiating EnterpriseServiceLocator a long with ServiceLocator but I don't what else to do since the getConsumer() method is only in the EnterpriseServiceLcoator object.

Any help would be greatly appreciated.  I've included both my delegate and ServiceLocator classes.

package control.delegates
	import com.adobe.cairngorm.business.ServiceLocator;
	import mx.messaging.Consumer;
	import mx.messaging.events.MessageEvent;
	import mx.rpc.IResponder;
	import mx.messaging.events.MessageFaultEvent;
	import com.adobe.cairngorm.enterprise.business.EnterpriseServiceLocator;
	public class ReceiveMessageDelegate
		private var _responder:IResponder;
		private var _service:Consumer;
		public function ReceiveMessageDelegate(r:IResponder)
			_service = EnterpriseServiceLocator.getInstance().getConsumer("receiveMessageEvent");
			_responder = r;
			_service.addEventListener(MessageEvent.MESSAGE, _responder.result);
			_service.addEventListener(MessageFaultEvent.FAULT, _responder.fault);
		// Subscribes to the feed.
		public function subscribe():void
		// Unsubscribes to the feed.
		public function unsubscribe():void
<!-------------- ServiceLocator ------------------>
<?xml version="1.0" encoding="utf-8"?>
<rds:ServiceLocator xmlns:rds="com.adobe.cairngorm.business.*"
			import model.ModelLocator;
			private var __model:ModelLocator=ModelLocator.getInstance();
	<mx:Consumer id="receiveMessageEvent" destination="ColdFusionGateway" />

Open in new window

Question by:blue44
  • 2

Accepted Solution

blue44 earned 0 total points
ID: 23608798
Of course, right after I posted this, I figured it out.  I'm not sure why this is the case, but you have to have Caringrom.swc and CairngormEnterprise.swc in the lib directory of your Flex project not as separate swcs -- if that makes sense.  This way, the getConsumer() method is available from the ServiceLocator class so there's no need to instantiate EnterpriseServiceLocater either.  Nasty, nasty, one...

Hope this helps some other hapless soul out there...

Expert Comment

ID: 30830610
Nice work blue44. Could you give an example of how you changed you code to accommodate this?

Author Comment

ID: 30844326
Well, it's been over a year so I had to go back and review the code.  All I did was manually add both the Cairngorm.swc and CairngormEnterprise.swc to the lib directory in a Flex Project (assuming you're utilizing Flex Builder).  Then, if you go to your project properties > Flex Build Path, you'll find both under the lib directory.  Hope this helps!

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question