Skip to content


Post transactional messenger.

Example.

We have a class that implements QueueService based on JmsTemplate (Spring)
Method sendMessage sends object to jms queue for future handle by message listeners
The problem is that queue injection should only be happens in case of successful transaction.

import org.springframework.jms.core.JmsTemplate;
import com.company.annotations.MessageQueue;
import com.company.jms.domain.QueueRequestHolder;
import com.company.jms.service.QueueService;

public class QueueServiceImpl implements QueueService
{
	private final JmsTemplate	jmsTemplate;

	public QueueServiceImpl(final JmsTemplate template)
	{
		jmsTemplate = template;
	}

	@MessageQueue()
	public QueueRequestHolder sendMessage(final Object objectToSend)
	{
		return new QueueRequestHolder(jmsTemplate, objectToSend);
	}

	public void sendMessageDirect(final Object objectToSend)
	{
		jmsTemplate.convertAndSend(objectToSend);

	}

}

Continued…

Posted in development.

Tagged with , , , , .


Buhsl captcha (or Secure Image)

Today I released version 1.0 of my captcha plugin. Please visit plugin page for more info

Posted in development, security.

Tagged with , , .


Drools configuration with Spring. Invoke processes over AOP (Part 3)

Example.

	@Transactional
	public void transfer(Account from, Account to, Double amount, final Boolean isSendNotification) throws Exception
	{
		couldDebit(from, amount);
		from.setAmmount(from.getAmmount() - amount);
		to.setAmmount(to.getAmmount() + amount);
		from.save();
		to.save();
		if( isSendNotification )
			emailQueue.sendMessage(createTransferNotification(from, to));
	}

We have a method ‘transfer’ in Account service transferd money from one customer account to another acount of same customer.
First, we validate that from account has enough amount of money.
Second, we transfer money.
And at the end we send notification using asyncronus queue email service.

Flow:

Continued…

Posted in development.

Tagged with , , , .


Drools configuration with Spring. Invoke processes over AOP (Part 2)

Previous post describe how to configure processes using Spring context. This article is about how to invoke process. The simple way is to create Workflow process factory and simply load

public class WorkflowProcessFactory{
...
public <T extends WorkflowProcess> T loadProcess(final Class<T> clazz) throws IllegalArgumentException, InstantiationException, IllegalAccessException,
			InvocationTargetException, SecurityException, NoSuchMethodException, IOException
	{
		final Map<String, ProcessDescriptor> descr = sessionLookup.getProcessConfig();
		final ProcessDescriptor pd = descr.get(clazz.getSimpleName());
		final Constructor<T> constr = clazz.getConstructor(StatefulKnowledgeSession.class);
		final StatefulKnowledgeSession session = sessionLookup.newSession(clazz.getSimpleName());

		return constr.newInstance(session);
	}

And use it in future

WorkflowProcessFactory factory;
....
FirstWorkflowProcess process = factory.loadProcess(FirstWorkflowProcess.class);

process.setSetter1("string");
process.setSetter2(new Integer(23));
String return = process.execute();

For example: you already have a buisness method that should be extended by adding new functionality. As example we need to change other objects and send different notifications (emails). For this purpose  I use next class.
Continued…

Posted in development.

Tagged with , , .


Drools configuration with Spring (Part 1)

Drools is a business rule management system (BRMS). It based on rules engine, using an implementation of the Rete algorithm.
Drools supports the JSR-94 standard for its business rule engine and enterprise framework for the construction, maintenance, and enforcement of business policies in an organization, application, or service.
More about Drools is here.

A business process or workflow describes the order in which a series of steps need to be executed, using a flow chart. This makes it much easier to describe a complex composition of various tasks. Processes are especially useful in describing state-based, long-running processes. Drools Flow allows end users to specify, execute and monitor (a part of) their business logic using these processes. The Drools Flow process framework is easily embeddable into any Java application (as a simple Java component) or can run standalone in a server environment.

This article is about practical implementation of rule flow with Spring. In my case  flow include validation step at beginning that validates objects, then executes several tasks. Execution of task depends on rules define in flow descriptor. Flow itself defined in flow file (.rf).

Simple flow diagram:

Before flow could execute we need to perform certain action as create session, load flow and validation (.drl) files, setup globals and work items for flow.  To simplify controls and manage this action I create integration classes.
Continued…

Posted in development.

Tagged with .