Bean Type
| |||
|---|---|---|---|
| Entity | Y | N | N |
| Session | Y | Y | Y |
| Message-driven | Y | Y | Y |
Callback
In computer programming, a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code.
Labels:
callback
JMS in Spring
If you used JMS before, you knew the drill. Before we could send/receive a message, we need create get a connection factory, then create a connection, start a connection, create a session, create a queue or topic, create a producer/consumer....and after that, we need clean up the connection and session.
Now enter Spring
All we need is inject a JmsTemplate and Destination to producer/consumer bean.
Here is how to send a message in producer bean.
Now enter Spring
All we need is inject a JmsTemplate and Destination to producer/consumer bean.
Here is how to send a message in producer bean.
jmsTemplate.send(destination,
new MessageCreator()
{
public Message createMessage(Session session) throws JMSException
{
TextMessage message = session.createTextMessage("Hello, World!");
return message;
}
});
Here is how to receive a message in consumer bean.Message message = (Message) jmsTemplate.receive(destination);Here is the configuration for JmsTemplate and Destination
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616"/> </bean> <bean id="queue_destination" class="org.apache.activemq.command.ActiveMQQueue"> <constructor-arg index="0" value="BolunQueue"/> </bean>You are welcome!
Regular Expression Example
^[0-9]+:
This will look for at the start of each line something like 1:
It's very useful to reformat some java codes which were posted with line number.
This will look for at the start of each line something like 1:
It's very useful to reformat some java codes which were posted with line number.
Labels:
Regular Expression
What's wrong with ActiveMQ version apache-activemq-5.5.0-bin.zip
I am trying to play with the most updated ActiveMQ: apache-activemq-5.5.0-bin.zip.
I thought it should be fairly easy. Download the zip file, unzip it, put lib\ and activemq-all-5.5.0.jar in classpath, and make sure java in PATH, I got everything covered.
But when I try to start activemq, I got an error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
Dear God, this drives me crazy, I could not figure it out anything that I did wrong to cause this, tried all the options that I could think of, finally I gave up, I told myself, what about try some other version, let's say, apache-activemq-5.4.2-bin.zip.
Guess what, it is working!
Labels:
ActiveMQ
Find + Grep
find . -name "*Extent.java" -exec echo "{}," \; -exec grep " CLASSNAME" '{}' > output.xml \;
This is search all the files ends with "Extent.java", print the name, then grep the line which contains "ClASSNAME", then put everything into output.xml
snippet of output.xml
/advising/src/com/dovetailsys/advising/Q5CNPBankRestrictionExtent.java,
public static final String CLASSNAME = "CNPBankRestriction";
This is search all the files ends with "Extent.java", print the name, then grep the line which contains "ClASSNAME", then put everything into output.xml
snippet of output.xml
/advising/src/com/dovetailsys/advising/Q5CNPBankRestrictionExtent.java,
public static final String CLASSNAME = "CNPBankRestriction";
JEE Transaction
2 types of transactions:
a. Container-managed transactions
b. Bean-managed transactions
Mandatory vs Never
NotSupported vs Supports
a. Container-managed transactions
b. Bean-managed transactions
Mandatory vs Never
NotSupported vs Supports
@TransactionAttribute(NOT_SUPPORTED)
@Stateful
public class TransactionBean implements Transaction {
...
@TransactionAttribute(REQUIRES_NEW)
public void firstMethod() {...}
@TransactionAttribute(REQUIRED)
public void secondMethod() {...}
public void thirdMethod() {...}
public void fourthMethod() {...}
}
Labels:
J2EE,
Transaction
Subscribe to:
Posts (Atom)