Hibernate Search 4 violates javax.jms.Message contract, incompatible with HornetQ

Description

I'm trying to create a JMS based indexer for Hibernate Search 4 running on AS7.

Supposing following producer:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @GET @Produces("text/xml") public Index indexMembers() throws Exception { Connection connection = connectionFactory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(hibernateSearchQueue); ObjectMessage message = session.createObjectMessage(); // this is not working on hornetq message.setStringProperty(JMSBackendQueueTask.INDEX_NAME_JMS_PROPERTY, "default"); producer.send(message); session.close(); return getIndexSize(); }

and following configuration:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="primary"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <!-- If you are running in a production environment, add a managed data source, the example data source is just for proofs of concept! --> <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> <properties> <!-- Properties for Hibernate --> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.show_sql" value="false" /> <!-- Properties for Hibernate Search --> <property name="hibernate.search.default.indexBase" value="target" /> <!-- optional --> <property name="hibernate.search.default.directory_provider" value="ram" /> <!-- Set worker to be a JMS based --> <property name="hibernate.search.default.worker.backend" value="jms" /> <!-- Set worker to work in a sync way --> <property name="hibernate.search.default.worker.execution" value="sync" /> <property name="hibernate.search.default.worker.jms.connection_factory" value="/ConnectionFactory" /> <property name="hibernate.search.default.worker.jms.queue" value="queue/hibernatesearch" /> <!-- optional, not used at the moment --> <!-- <property name="hibernate.search.default.worker.jndi.*" /> --> </properties> </persistence-unit> </persistence>

and

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @MessageDriven(activationConfig = { //@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "org.hornetq.jms.client.HornetQQueue"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/hibernatesearch"), @ActivationConfigProperty(propertyName = "DLQMaxResent", propertyValue = "1") }) public class HSearchController extends AbstractJMSHibernateSearchController implements MessageListener { @Inject EntityManager em; // method retrieving the appropriate session protected Session getSession() { return (Session) em.getDelegate(); } // potentially close the session opened in #getSession(), not needed here protected void cleanSessionIfNeeded(Session session) { } }

This leads to the error when triggered on AS7 with HQ:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 java.lang.IllegalArgumentException: The property name 'hibernate.search.jms.indexNameProperty' is not a valid java identifier. org.hornetq.jms.client.HornetQMessage.checkProperty(HornetQMessage.java:1032) org.hornetq.jms.client.HornetQMessage.setStringProperty(HornetQMessage.java:793) org.jboss.as.quickstarts.kitchensink.rest.HSearchIndexationRESTService.indexMembers(HSearchIndexationRESTService.java:57) org.jboss.as.quickstarts.kitchensink.rest.HSearchIndexationRESTService$Proxy$_$$_WeldClientProxy.indexMembers(HSearchIndexationRESTService$Proxy$_$$_WeldClientProxy.java) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140) org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255) org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220) org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209) org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

which is indeed correct, check http://docs.oracle.com/javaee/5/api/javax/jms/Message.html and Message Selector / Identifiers section.

Without this property, the code fail with:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 10:55:41,125 ERROR [org.hornetq.ra.inflow.HornetQMessageHandler] (Thread-18 (group:HornetQ-client-global-threads-898159460)) Failed to deliver message: java.lang.IllegalArgumentException: HSEARCH000113: 'null' is not a valid index name at org.hibernate.search.indexes.impl.IndexManagerHolder.getIndexManager(IndexManagerHolder.java:309) at org.hibernate.search.backend.impl.jms.AbstractJMSHibernateSearchController.onMessage(AbstractJMSHibernateSearchController.java:101) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_27] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_27] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_27] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27] at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:122) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:130) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:59) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:225) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.as.ejb3.component.interceptors.EjbClientContextInterceptorFactory$1.processInvocation(EjbClientContextInterceptorFactory.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:156) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:166) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) at javax.jms.MessageListener$$$view28.onMessage(Unknown Source) at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_27] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27] at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140) at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73) at $Proxy162.onMessage(Unknown Source) at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278) at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:866) at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:44) at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:983) at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27] at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]

Environment

None

Status

Assignee

Sanne Grinovero

Reporter

Karel Piwko

Labels

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Affects versions

4.0.0.CR2

Priority

Blocker