Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Spring Integration

Reply
 
Thread Tools Display Modes
  #1  
Old Aug 28th, 2008, 06:55 AM
amsmota amsmota is offline
Senior Member
 
Join Date: Feb 2008
Location: Dublin - Ireland
Posts: 101
Default Gateway questions and sugestions

I spend the last few days implementing a Gateway and I have a few questions and suggestions.

Q1) Seeing the example in GatewayProxyFactoryBeanTests, I realised that although there is a Interface for the Gateway, nowhere is to be found a Implementation of that Interface. Why is that? In my use case we need both (Interface and Implementation) which I had to "hand code" myself.

Q2) How can I access the Gateway properties (request-channel, reply-channel, message-creator, etc...) from within the code? Once I injected the Gateway as my Interface in my code, I can do something like

Code:
Advised gat = (Advised) gateway;
DefaultPointcutAdvisor d = (DefaultPointcutAdvisor)gat.getAdvisors()[0];
((GatewayProxyFactoryBean)d.getAdvice()).xxx
but I have then the setRequestChannel etc. but not the corresponding gets. I do need to access the Channels, and now I'm doing it by injecting manually alongside the Gateway.

Q3) If I understand correctly, Gateway is only used to "fire&forget" messages and synchronous Request/Reply messages. Is there a way to extend this to support other kind of messaging (asynchronous, with correlationId, synchronous-that-fall-down-to-assyncrounous-with-correlationId-on-time-out, etc...)?

S1) Ways to provide access to what I just said in Q2, if there aren't any that I don't know about.

S2) Ways to implement Q3.

S3) When I invoke a method of my Interface thru the Gateway, it will be useful that the invoked method signature goes in the Headers of the wrapper message, like a "internal.header.invokedmethod" key. I implemented that but it was a pain in the ***.

S4) Following Q1 and S3, and supposing there aren't any methods to do that that I'm unaware of, it will be interesting to provide a way to map the Interface method call to the same (implemented) method of a service activator handler. Again, I implemented my own version, but again painfully...

S5) Add a "errorChannel" to the Gateway, to avoid the Dead Letter problem.

Overall, I'm very happy with the way things are turning, thanks for your excellent work, I wish I could contribute more.

Last edited by amsmota; Aug 28th, 2008 at 08:41 AM.
Reply With Quote
  #2  
Old Aug 28th, 2008, 07:57 AM
Mark Fisher Mark Fisher is offline
Senior Member
Spring Team
 
Join Date: Oct 2005
Location: Boston, MA
Posts: 1,355
Default

I think I would recommend against using the gateway in your case. The main purpose of the gateway is to generate a proxy (the implementation) behind the scenes so that all of the messaging components (channels and messages themselves) are hidden from the user. This works well when you simply want to invoke a method that triggers a simple send and/or receive across MessageChannels. In that sense, the idea behind gateway is similar to that of other Spring ProxyFactoryBeans (RMI, HttpInvoker, etc).

In your case, however, you clearly do want to be aware of the Message and the MessageChannels. So, perhaps you should just create your own "client" object and use dependency injection to provide the channels. Then, use the MessageBuilder to create the Messages. For simple send and receive operations, you can also use the MessageExchangeTemplate. There is nothing wrong with that approach either.

In general, anytime you find yourself accessing the target object of a proxy, it is a good sign that you don't need the proxy. Its purpose is to hide the details, but in your case, you want to know the details, and thus the proxy is getting in the way.

Hope that helps.

-Mark
__________________
Mark Fisher
Senior Software Engineer, SpringSource
Spring Integration Lead
http://www.springsource.com
http://www.springsource.org/spring-integration
http://blog.springsource.com/main/author/markf
Reply With Quote
  #3  
Old Aug 28th, 2008, 08:57 AM
amsmota amsmota is offline
Senior Member
 
Join Date: Feb 2008
Location: Dublin - Ireland
Posts: 101
Default

But i like the gateway ... I think it gives me what I need, i.e. a way for developers to define their services without even think about the messaging platform. Basically, I want then to write code like (using Jersey annotations now)

Code:
@Path("/ExampleService")
public interface ITestService {

	@Path("/ExampleService/{name}/{delay}")
	String sayHello(@PathParam("name")String name, @PathParam("delay")int delay);
	
	@Path("/ExampleService/{name}")
	String sayHello(@PathParam("name")String name);

}
and
Code:
public class TestService implements ITestService{
	public String sayHello(final String name, int delay) {
		try {
			Thread.sleep(delay *1000);
		} catch (InterruptedException e) {
			return String.format("Too much time, sorry");
		}
		return String.format("Hello %s (after %s seconds)!", name, delay);
	}
	public String sayHello(final String name) {
		return String.format("Hello %s!", name);
	}
}
and then just simply assign those to the gateway and service-activator respectively.

I have this working now, I just want to refine the all thing. Hence my suggestions. Now I see that Q2/S1 can be implemented with a MessageSelector, S2 and S5 I already implemented, but Q3/S2 and S5 will be important for my goal.

Cheers.
Reply With Quote
  #4  
Old Aug 29th, 2008, 06:15 AM
amsmota amsmota is offline
Senior Member
 
Join Date: Feb 2008
Location: Dublin - Ireland
Posts: 101
Default

For now, we dropped all of our questions regarding the assync messaging and we'll live with the Fire & Forget and the Synch yokes.

However we are still concerned about the Error Channel and the Dead Letter Channel. Have you guys something in mind to implement them in Gateway, or do you have some kind of strategy to deal with this?

If not it's ok, I just implement them myself, but I'll like to do it in a "compatible" way with the "big picture" that I'm probably not seeing in their full extension.

Cheers.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:47 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.