Showing posts from 2014

JEE Concurrent with Camel

The official specs for JEE servers, say that your not meant to start your own threads, implying an impending doom if you do so. In actually you loose some functionality in terms of what the app server provides/allows and the app server isn't easily able to kill off rogue threads when you try and undeploy. Not the worst things in the world but if we could do something about it we would. The first 'standard' support for spawning threads in a container was the commonj Work Manager and Timer . It was a bit clunky to use, hard to integrate and not supported across the board. Thankfully they made the smart decision to just extend Doug Lea's framework in concurrency-ee . Integrating this into camel but substituting the used ThreadFactory with the container provided ManagedThreadFactory. The one downside of doing this is that we loose don't create the threads so we may not be able to set the name. Having said that, using a nifty trick I was able to set it on Websphere Lib

Suppressing class path jaxb-api.jar can not be found

When loading an application in an osgi-like container with an app that references jabx-impl, you might see the following warning: [WARNING ] SRVE9967W: The manifest class path jaxb-api.jar can not be found in jar file file:/D:/Java/maven/repo/com/sun/xml/bind/jaxb-impl/2.2.7/jaxb-impl-2.2.7.jar or its parent. [WARNING ] SRVE9967W: The manifest class path jaxb-core.jar can not be found in jar file file:/D:/Java/maven/repo/com/sun/xml/bind/jaxb-impl/2.2.7/jaxb-core.jar.jar or its parent. This one is caused by the specific reference to jaxb-api.jar and jaxb-core.jar in jaxb-impl-2.2.7.jar/META-INF/MANIFEST.MF: Class-Path: jaxb-api.jar jaxb-core.jar The artifacts that maven pull in have a different filename (with a version number) that doesn't match the expected build version. e.g. jaxb-core-2.2.7.jar and jaxb-api-2.2.7.jar The solution: Create 2 empty zip files and name them jaxb-core.jar and jaxb-api.jar Place them into proj/src/main/WEB-INF/lib Done

Using SQL Server as an imitation Queue with Camel

SQL Server's lock hints allow to you to use it as a database queue. The general process is discussed on stackoverflow . Here I wanted to summarise the different ways it can be configured with the camel-jpa component. Testing was done against SQL Server 2008 R2 Developer Edition. The list of locks was obtained using this useful script from Microsoft . Assume we have a generic entity: @Entity public class JpaMessage { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; /** an optional hint as to type of message */ private String msgType; /** a refrence to another table containing the blob for performance reasons */ private Long msgBlobId; /** to allow for PESSIMISTIC locking */ @Version private Date lastUpdated; } /** basic route */ public class TestRoutbuiler extends BaseRouteBuilder { @Value("${endpoint.uri}") private String endpointUri; @Override public void configure() throws Exception {

Setting ApplIdentityData on a Liberty Profile defined queue

Setting the necessary properties on the Java Client for MQ libraries in order to pass the ApplIdentityData is quiet simple, as mentioned in this stackoverflow post : MQDestination queue; //... queue.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true); queue.setBooleanProperty(WMQConstants.WMQ_MQMD_READ_ENABLED, true); queue.setIntProperty(WMQConstants.WMQ_MQMD_MESSAGE_CONTEXT, WMQConstants.WMQ_MDCTX_SET_ALL_CONTEXT); javax.jms.Message message; //... message.setStringProperty(JmsConstants.JMS_IBM_MQMD_APPLIDENTITYDATA, "...."); The meaning of the properties is listed in the documentation: Destination object properties . If using Websphere Application Server, you can define a Jms Queue as a Resource which can be intern looked up via JNDI. IBM has a pretty good summary of the different methods. How to read and write fields from the MQMD via WebSphere MQ Classes for JMS Version 7: direct, using JNDI and using WebSphere Application Server . To set it up in WAS7 f

Limitations of compile time woven spring-aspects

The compile time woven aspectj spring-aspects provides some very useful features. The features I was after was: transactional boundaries between methods in the same bean. e.g. nonTransactionMethod() calling requiresNewMethod() without having to use self references or manually handling the transactions. consistent results between testing in Eclipse, testing via maven and running on the server (instead of using the loadtime weaver) During testing in both eclipse and maven I started getting exceptions of the likes "NoTransactionException". The individual test would pass fine but when running all the tests together they would fail. Debugging through the tests showed that transaction manager was still being called but it was the wrong one! Decompiling the aspectj woven code shows the reason. My simple class: package net.devgrok; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.aspectj.AbstractTransactionAspect; impo