JGuru
When you need a guru
  • Home
  • About
  • Services
  • Blog
  • Projects
    • Liferay Backup
    • Photo Carousel Portlet
    • Social Comments Portlet
    • Liferay Yubikey OTP Login
  • Contact
September 1 2010

How do I cluster Liferay with Terracotta?

Mika Koivisto Liferay cluster, liferay, terracotta

That’s a question I’ve head many times and in this post I will show you  just how to do that. These instructions are for Liferay 6 CE GA3 Tomcat 6.0 bundle however you can use any app server supported by Terracotta but the location and some configuration might be slightly different. So to get started you need to download: More

August 24 2010

Using Freemarker in your theme templates

Mika Koivisto Liferay freemarker, liferay, theme

Freemarker is a template language very similar to Velocity. Starting from Liferay 6.0 Liferay supports also Freemarker templates in themes and Web Content templates. In this post I will show how you can use Freemarker in your themes. More

December 15 2009

Liferay Maven SDK

Mika Koivisto Liferay liferay, maven

Starting to recover from jetlag after a two week trip Los Angeles and Liferay retreat. One of the things we finally made some progress during the developer retreat  is providing official maven artifacts for Liferay as well as porting our plugins sdk to Maven. Things are not quite completed but I will provide some instructions here for all early adopters. More

October 3 2008

SiteMinder integration is here

Mika Koivisto Liferay liferay, siteminder, sso

You’ve been heard! Out of box SiteMinder integration is here.

Computer Associate’s (CA) SiteMinder is a centralized web access management system that enables user authentication and single sign-on, policy-based authorization, identity federation, and auditing of access to Web applications and portals.

Liferay has out of box SiteMinder integration as of recent Liferay 5.1.2 release. The integration is based on CAS integration and only supports authenticating with screenName. It also knows how to properly terminate SiteMinder session. SiteMinder is usually connected to a LDAP so this integration is also able to import users from LDAP. More

December 11 2007

Configuring ActiveMQ 5 jms topic in Tomcat 6

Mika Koivisto Howto activemq, jms, spring 0

For some reason it is quite difficult to find a clear instruction on howto configure ActiveMQ jms topic in tomcat as a JNDI reference and the consume message from it into message driven pojo. I chose to use ActiveMQ 5 since it requires less dependent libraries to run than previous versions.

Start by downloading ActiveMQ 5.0.0 from Apache ActiveMQ site

You need following jars to be located under CATALINA_HOME/lib:
– activemq-core-5.0.0.jar
– commons-logging-1.1.jar
– geronimo-j2ee-management_1.0_spec-1.0.jar (or another jar that has javax.management apis)
– geronimo-jms_1.1_spec-1.0.jar (or another jar that has javax.jms apis)
– geronimo-jta_1.0.1B_spec-1.0.jar (or another jar that has javax.transaction apis)

You can find above libraries from ACTIVEMQ_HOME/lib

That configure the topic and connection factory to CATALINA_HOME/conf/server.xml

<Resource 
	name="jms/ConnectionFactory" 
	auth="Container" 
	type="org.apache.activemq.ActiveMQConnectionFactory" 
	description="JMS Connection Factory"
	factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
	brokerURL="vm://localhost" brokerName="LocalActiveMQBroker"/>

<Resource 
	name="jms/SampleTopic" 
	auth="Container" 
	type="org.apache.activemq.command.ActiveMQTopic" 
	description="my Topic"
	factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
	physicalName="SAMPLE.TOPIC"/>

Then you need to add resource-link to either CATALINA_HOME/conf/context.xml or webapps META-INF/context.xml

<Context>
....
	<ResourceLink global="jms/ConnectionFactory" name="jms/ConnectionFactory" type="javax.jms.ConnectionFactory"/>
	<ResourceLink global="jms/SampleTopic" name="jms/SampleTopic" type="javax.jms.Topic"/>
</context>

You also need to add a resource-ref to your webapps web.xml

<resource-ref>
	<res-ref-name>jms/ConnectionFactory</res-ref-name>
	<res-type>javax.jms.ConnectionFactory</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>	
<resource-ref>
	<res-ref-name>jms/SampleTopic</res-ref-name>
	<res-type>javax.jms.Topic</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Then configure message driven pojo with spring. You should notice that this is really a pojo that does not know anything about jms.

 

package fi.javaguru.mdp;

public class SamplePojo {

    public void doSomething(final String msg) {

        System.out.println("Got message: " + msg);
    }
}

Spring configuration for consuming messages

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">

    <jee:jndi-lookup id="jmsConnectionFactory" jndi-name="jms/ConnectionFactory" resource-ref="true"/>
    <jee:jndi-lookup id="jmsTopic" jndi-name="jms/SampleTopic"
		resource-ref="true" proxy-interface="javax.jms.Topic"/>

    <bean id="pojo" class="fi.javaguru.mdp.SamplePojo" />
	
    <bean id="listener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
        <property name="delegate" ref="pojo"/>
        <property name="defaultListenerMethod" value="doSomething"/>
    </bean>

    <bean id="container" class="org.springframework.jms.listener.SimpleMessageListenerContainer">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
        <property name="messageListener" ref="listener"/>
        <property name="destination" ref="jmsTopic"/>
    </bean>

</beans>

This sample assumes you are sending String messages to the topic. You could also send other objects as long as the consumer knows about those objects. Thats it for now. I will write another post later that will continue this sample with producing messages to a topic.

1 2 3 4

Tags

activemq apache backup c3p0 certificate connection pool debian debugging deployment git heap hook httpd https installer java jms jmx jmx4perl jndi jolokia jvm liferay mariadb maven memory monitoring mrtg mysql nagios newrelic nginx ngx_cache_purge pagespeed performance repository salesforce saml security spring ssl struts tls tomcat ubuntu

Categories

  • General
  • Howto
  • Liferay

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Archives

  • October 2017
  • February 2017
  • January 2017
  • July 2016
  • June 2016
  • May 2016
  • August 2015
  • April 2015
  • January 2015
  • October 2013
  • June 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • March 2012
  • February 2012
  • January 2012
  • January 2011
  • September 2010
  • August 2010
  • December 2009
  • October 2008
  • December 2007

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Follow me on Twitter

My Tweets
© JGuru 2006 - 2017