Sunday, January 10, 2010

A Decent email while leaving an organization.

As many of you may have heard, I have decided to leave to pursue an opportunity at . Over the past years I have been at this company, I have been privileged to meet and work with many talented people. I have thoroughly enjoyed my time here and wish everyone nothing but success.

While I have tried to include as many people as I could on this note, I am sure I forgot a few. Please feel free to forward this on to anyone I may have missed. My contact info is below:

Email: abc@def.com

I am also available via linkedin (www.linkedin.com)

Wednesday, November 11, 2009

How to access JNDI from Spring's Application Context

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/MyDataSource"/>
</bean>

<bean id="userDao" class="com.foo.JdbcUserDao">
<!-- Spring will do the cast automatically (as usual) -->
<property name="dataSource" ref="dataSource"/>
</bean>

Tuesday, November 10, 2009

Spring JMS message consumer ( JBoss MQ )

  1. Create a new web project in eclipse.
  2. Under the WEB-INF/lib folder copy the following jar files
    1. commons-logging.jar
    2. spring.jar
    3. spring-jms.jar
  3. Create a listener bean
  4. package com.test.jms.pojo;
    
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.TextMessage;
    
    public class Listener1 implements MessageListener {
    
     public void onMessage(Message message) {
      if (message instanceof TextMessage) {
       try {
        System.out.println(((TextMessage) message).getText());
       } catch (JMSException ex) {
        throw new RuntimeException(ex);
       }
      } else {
       throw new IllegalArgumentException(
         "Message must be of type TextMessage");
      }
    
     }
    
    }
  5. Create Spring configuration file.
  6. <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://www.springframework.org/schema/beans"
     xsi:schemalocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
     <bean class="com.test.jms.pojo.Listener1" id="listener1">
      <bean
       class="org.springframework.jms.listener.DefaultMessageListenerContainer"
       id="jmsContainer">
       <property name="connectionFactory" ref="connectionFactory"></property>
       <property name="destination" ref="c8queue"></property>
       <property name="messageListener" ref="listener1"></property>
      </bean>
      <bean class="org.springframework.jms.core.JmsTemplate" id="jmsTemplate">
       <property name="connectionFactory" ref="connectionFactory"></property>
      </bean>
      <bean class="org.springframework.jndi.JndiObjectFactoryBean" id="c8queue">
       <property name="jndiName" value="queue/c8queue"></property>
       <property name="jndiTemplate" ref="jndiTemplate"></property>
       <property name="resourceRef" value="false"></property>
      </bean>
      <bean class="org.springframework.jndi.JndiObjectFactoryBean" id="connectionFactory">
       <property name="jndiName" value="ConnectionFactory"></property>
       <property name="jndiTemplate" ref="jndiTemplate"></property>
       <property name="resourceRef" value="false"></property>
      </bean>
      <bean class="org.springframework.jndi.JndiTemplate" id="jndiTemplate">
       <property name="environment">
        <props>
         <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory </prop>
         <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
         <prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces </prop>
        </props>
       </property>
      </bean>
     </bean>
    
  7. Create queue in Jboss
    1. In folder $JBOSS_HOME/server/default/deploy/jms create a file yourProj-service.xml
    2. <server>
       <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=c8queue">
        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager </depends>
        <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager </depends>
        <attribute name="MessageCounterHistoryDayLimit">-1</attribute>
        <attribute name="SecurityConf">
         <security>
          <role name="guest" read="true" write="true">
           <role create="false" name="publisher" read="true" write="true">
            <role create="false" name="noacc" read="false" write="false"></role>
           </role>
          </role>
         </security>
        </attribute>
       </mbean>
      </server>
      
  8. Edit web.xml to load spring configuration
  9. <web-app id="WebApp_ID" version="2.5"
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
     xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     <display-name>tstSprJms</display-name>
     <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
     </welcome-file-list>
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>WEB-INF/applicationContext.xml</param-value>
     </context-param>
     <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
    </web-app>
    
  10. Restart the server

    Monday, November 9, 2009

    Wedding shopping in Delhi

    Two weeks back me and my bro. were shopping for my wedding, I earlier decided to wear suit but then after discussion with my friends I finalized to sherwani, looking for suit for my bro we went though a lot of shops in karol bagh but we didn't find anything that justified the price. we then shifted our focus towards CP, were the collection of suits was nice and we could easily finalize suit for sumit. for sherwani my friends suggested chandini chowk, we went there and found a good collection of sherwanis, most of the shops were quite congested with little or no space to even change but the level of bargining that you do was amazing, for instance we finalized on a sherwani that the deler was quoting to be as Rs 12500, and will some barganing we were able to buy the same sherwani for Rs 5000. So whenever you are looking forward to shop for sarees, lahenga, sherwani, etc. Chandini Chowk is the place to look for.
    and if you plan to go there don't miss the paranthe wali gali and natraj ke dhahi bhalle :)

    Sunday, November 8, 2009

    Karmic Koala - a worth upgrade.

    Recently I upgraded my ubuntu from 9.04 to 9.10, and as always I am really happy after installing the new verison, its looks have improved, even the console is very beautifull, hardware support for Nvidia cards can be seen right from the installation screen. overall I would say that it is worth spending few hrs and upgrade.

    Thursday, November 5, 2009

    Mata Vaishno Devi Yatra 09

    As every year Maa called us this year also, since so many years every yatra has been memorable but this one had interesting experiences. One day before we boarded on the train on Thursday, 22nd Oct evening there were few cancellations from the people who were expected to travel with us this may sound strange but over the years I have seen this is a normal trend that happens when we plan 2 months in advance. varun on the other hand planned to join us at the eleventh hour. even the start was shaky as most of our tickets got confirmed the same day we were not sure about our coatch. but some how we found our seats and the train in an overnight journey took us to Jammu, I was surprised to see a lot of people in karta as this being not a weekend travel I was expecting much less traffic. we quickly got ready in keshav ashram, and started yatra, I was keenly looking forward towards baan ganga but it was a disappointing scene to find very less water in the stream, which draws us to a conclusion that one should not prefer planning yatra on Oct , as far as I remember I have seen ample of water when I used to come around Nov, Feb, March. I had a new camera and enjoyed taking a lot of pics all the way up and down the hill, a silly mistake from me was enough for 4 of us to miss the train (on our way back to delhi) in the end, and it will be a memorable evening how we struggled all night to find some place to sleep for few hours.

    Sunday, September 27, 2009

    My last month of being a bachelor.

    This sounds scary, isint it. Somehow I don't feel scared or over exited or anything like that. One month from now I am going to get married with a girl whome I have known since quite some time now, I am happy that I am stepping into the next phase of this "circle of life", I don't know how most of the people at this stage would be feeling like but I am sure they too must be feeling some sort of mixed feelings including the fear that they i'll loose the indipendence that they are used to, increased financial focus to save and spend very conservatively, now you won't have to cook anymore :), a slight fear that the new person will gel well with your family or not, and finally a big time question of whether this is the starting point or the end point of happiness in your life.
    Statistics collected from the people that I know who got married it looks like life becomes more stabilized and organised and you become a serious person. If you are a software developer I can put in simple words it is like you started using frameworks rather that adhoc coding methodologies :)
    Last few weeks some of my friends put up a question to me saying you must be very exited as it is just around a month left for your marriage, humm.... it was a difficult question for me, I have asked this question to me many times that are people during this time on the seventh sky, or they are too troubled by the questions going in their head. because I for sure don't see my self on seventh sky but in my case I know her since quite some time and so the understanding is quite clear and the question don't seem to bother me a lot, and thats when I start analyzing that I am so boring kind of a person, or people of my age group closing in to thirty become like this.
    I am quite positive overall, I am not working too hard on it, not changing anything in my lifestyle, not planning too much and just trying to wait and watch how life takes this twist.