[Messaging, JMS & JBossMQ] - Joining messages (queues)
by obfuscator
Hi!
I have the following use case:
*Wait for a free resource
*When resource is free, wait for next job, then use resource to process job.
So, i need to wait until there is BOTH a resource and a job available. All resources are equal, so I can use any resource with any job.
What's the best way of accomplishing this?
My current (flawed?) implementation is as follows:
I'm putting the resources in one queue as they become available, and then I have an MDB registered for that queue (P2P).
The job queue is a separate queue, and jobs are added to the queue as soon as a request arrives (might be days or months between jobs, then suddenly I could get a large amount at once).
When a resource is ready, the onMessage()-method of my MDB is called.
In this method, I then create a MessageConsumer for the job-queue, and call receive() with infinite timeout. This seems to be a sub-optimal solution, since i'm blocking the MDB thread and Jboss AS seems to dislike my approach (refuses to shutdown while thread is blocked) ;)
I've also tried another solution, where I have a n second timeout on the receive method, and call ctx.setRollbackOnly() if no job is available when a resource is free.
This makes JBoss assume that the operation failed non-intentionally and puts all my messages in the dead-letter-queue after 10 retries. I could increase the max amount of retries, but it feels like I'm going down the wrong road here... Is there a nicer way of joining messages?
I basically have free hands when it comes to this, so any suggestion is more than welcomed!
Best regards
Alex
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007629#4007629
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007629
19 years, 2 months
[JBoss jBPM] - db connection leak some advice please
by bentins
I have recently deployed a large jbpm application. This is actually an extension to a J2ee application which has been running for two years. Since this deployment my system exhausted the connection pool every few hours. It looks like JBPM is responsible (or rather me misusing it....)
Anyhow, I read somewhere that not closing JbpmContext could be the reason for this problem. However, I'm running most of my jbpm calls from code that does other things and which uses a UserTransaction (I'm working with ejb 2.0 on jboss4.0.3Sp1). If I try to close the context it complains I can't commit when autocommit is set!, so basically I commit my userTransaction and don't close the JbpmContext.
Here are my configuration files:
| <hibernate-configuration>
| <session-factory>
|
|
| <!-- Datasource configuration -->
| <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
| <property name="hibernate.connection.datasource">java:/OracleDS</property>
| <property name="hibernate.show_sql">false</property>
| <property name="hibernate.format_sql">false</property>
| <!--
| <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
| -->
| <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
| <property name="hibernate.connection.release_mode">after_statement</property>
| <!--
| <property name="hibernate.transaction.auto_close_session">true</property>
| -->
| <property name="hibernate.transaction.flush_before_completion">true</property>
|
| <!-- other hibernate properties
| <property name="hibernate.show_sql">true</property>
| <property name="hibernate.format_sql">true</property>
| -->
|
and jbpmConfig:
| <jbpm-configuration>
|
| <jbpm-context>
| <service name='persistence' factory='org.jbpm.persistence.db.DbPersistenceServiceFactory'>
| <field name="isTransactionEnabled"><false /></field>
| </service>
| <service name='message' factory='org.jbpm.msg.db.DbMessageServiceFactory' />
| <!-- service name='scheduler' factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' /-->
| <service name='logging' factory='org.jbpm.logging.db.DbLoggingServiceFactory' />
| <!-- service name='authentication' factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' /-->
| </jbpm-context>
|
| <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
| <string name='resource.hibernate.cfg.xml' value='hibernate.cfg.xml' />
| <!-- <string name='resource.hibernate.properties' value='hibernate.properties' /> -->
| <string name='resource.business.calendar' value='org/jbpm/calendar/jbpm.business.calendar.properties' />
| <string name='resource.default.modules' value='org/jbpm/graph/def/jbpm.default.modules.properties' />
| <string name='resource.converter' value='org/jbpm/db/hibernate/jbpm.converter.properties' />
| <string name='resource.action.types' value='org/jbpm/graph/action/action.types.xml' />
| <string name='resource.node.types' value='org/jbpm/graph/node/node.types.xml' />
| <string name='resource.parsers' value='org/jbpm/jpdl/par/jbpm.parsers.xml' />
| <string name='resource.varmapping' value='org/jbpm/context/exe/jbpm.varmapping.xml' />
|
| <bean name='jbpm.task.instance.factory' class='com.emi.framework.infrastructure.workflow.TaskInstanceFactory' singleton='true' />
| <bean name='jbpm.variable.resolver' class='org.jbpm.jpdl.el.impl.JbpmVariableResolver' singleton='true' />
| <long name='jbpm.msg.wait.timout' value='5000' singleton='true' />
|
| </jbpm-configuration>
|
can someone shed a light?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007598#4007598
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007598
19 years, 2 months
[Management, JMX/JBoss] - Preregister() not being called on MBean before attribute se
by bdouglas
Hi,
I'm trying to get JPoller (http://sourceforge.net/projects/jpoller) working with JBoss 4.0.5 and have run into a problem. It appears that the preRegister() is not being called when I set the poller up to run as a MBean.
We have configured it to use a factory to generate the PollManagers:
| <mbean code="org.sadun.util.polling.ManagedDirectoryPoller" name="user:service=DirectoryPoller">
| <attribute name="Verbose">true</attribute>
| <attribute name="PollInterval">1000</attribute>
| <attribute name="StartBySleeping">true</attribute>
| <attribute name="ControlledDirectories">c:\download\spurwing</attribute>
| <attribute name="PollManagerFactoryClass">com.synyati.spurwing.download.SpurwingPollManagerFactory</attribute>
| </mbean>
|
The ManagedDirectoryPoller class implments MBeanRegistration:
| public class ManagedDirectoryPoller
| extends DirectoryPoller
| implements ManagedDirectoryPollerMBean, MBeanRegistration, NotificationListener, NotificationBroadcaster {
| ...
|
and the preRegister() method stores the MBean name:
| public ObjectName preRegister(MBeanServer server, ObjectName name)
| throws Exception {
| pollerMBeanName=name;
| return name;
| }
|
The setter for the PollFactoryClass attribute does a check to see if the MBean name is set:
| public void setPollManagerFactoryClass(String newFactoryClsName) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
| ...
| if (pollerMBeanName==null) throw new RuntimeException("PreRegister hasn't been called on this bean - poller bean name is null");
| ...
|
When we start our application the server, that exception in setPollManagerFactoryClass() is being thrown. Can anyone give any insight into what's gone awry here, or point me to any doco on the lifecycle of MBeans (particularly with reference to the MBeanRegistration interface) within JBoss?
Sorry is this is already covered somewhere I should have been able to find, but I did dig around for answers before posting here and came up blank.
Thanks,
Brad
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007597#4007597
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007597
19 years, 2 months