I've found that I need to have two gateways. The first represents the non-messaging contract, the second, the messaging contract. I'm generating service activators to handle asynchronous returns, errors, timeouts, nulls, etc, as shown here.
My configuration is like this:
The first gateway aggregates all parameters into a single java object. That object is serializable via JaxB. All my methods take the same object, but all variables are set to null unless set by payload expression.HTML Code:<bean id="cartridgeServiceAggregator" class="payload.CartridgeServiceAggregator"/> <int:gateway id="cartridgeServiceGateway" service-interface="ICartridgeServiceGateway" default-request-channel="cartridgeservice-request-channel-gateway" default-reply-channel="cartridgeservice-reply-channel"> <int:method name="getBarCodeTemplates" payload-expression="@cartridgeServiceParms.aggregateGetBarCodeTemplates( )"/> <int:method name="addBarCodeTemplate" payload-expression="@cartridgeServiceParms.aggregateAddBarCodeTemplate( #args[0], #args[1], #args[2], #args[3] )"/> <int:method name="deleteBarCodeTemplate" payload- <int:method name="getCartridges" payload-expression="@cartridgeServiceParms.aggregateGetCartridges( #args[0], #args[1], #args[2], #args[3] )"/> </int:gateway> <int:service-activator id="cartridgeservice-request-channel-activator" input-channel="cartridgeservice-request-channel-gateway"> <bean class="com.sepaton.vtl.api.gateway.core.contracts.activators.CartridgeServiceServiceActivator"> <constructor-arg name="messagingGateway" ref="cartridgeServiceGateway-async"/> </bean> </int:service-activator> <int:channel id="cartridgeservice-request-channel-msg-gateway"> <int:dispatcher task-executor="vtlEsbExecutor"/> </int:channel> <int:gateway id="cartridgeServiceGateway-async" service-interface="ICartridgeServiceMessagingGateway" default-request-channel="cartridgeservice-request-channel-msg-gateway" default-reply-timeout="6000"/>
The activator implements all the methods like this:
The original gateway had a bunch of parameters, this activator accepts a signature that is just the aggregated payload object. This isn't done as you can see. But it should get called.Code:public ResultObject<CartridgeResults> getCartridges(CartridgeServiceParms message) { //throws InterruptedException, ExecutionException, TimeoutException try { Future<ResultObject<CartridgeResults>> futureResponse = messagingGateway.getCartridges(message); return futureResponse.get(15, TimeUnit.SECONDS); } catch (Exception e) { // Eat it for now return null; } }
The messaging interface looks just like the original gateway interface, except that it wraps returns as Future, and has the aggregate object for a parameter. For the method shown above, it looks like this:
Original gateway interface:
Messaging gateway interface:Code:ResultObject<CartridgeResults> getCartridges(String barcodePrefix, String barcodeSuffix, int barcodeStartIndex, int barcodeEndIndex);
When I try to execute a test call on this gateway, there is an error. The gateways are built, but there is an error processing the service activator:Code:Future<ResultObject<CartridgeResults>> getCartridges(CartridgeServiceParms parms);
I've seen this error in other threads, but older ones, and reports that the error has been fixed. Does anyone know what this could be?java.lang.IllegalArgumentException: Found ambiguous parameter type [class parms.CartridgeServiceParms] for method match: [public java.lang.String com.sepaton.vtl.api.gateway.core.contracts.activat ors.CartridgeServiceServiceActivator.getCartInfoFo rLibrary(parms.CartridgeServiceParms)]


Reply With Quote
