0
votes

Following is my spring configuration for aws sqs.

<bean id="CredentialsProviderBean"
    class="com.myapp.util.ClasspathPropertiesFileCredentialsProvider" />

<bean id="ConnectionFactoryBuilder"
    class="com.amazon.sqs.javamessaging.SQSConnectionFactory$Builder">
    <property name="regionName" value="us-east-1" />
    <property name="numberOfMessagesToPrefetch" value="1" />
    <property name="awsCredentialsProvider" ref="CredentialsProviderBean" />
</bean>

<bean id="ConnectionFactory" class="com.amazon.sqs.javamessaging.SQSConnectionFactory"
    factory-bean="ConnectionFactoryBuilder" factory-method="build" />

<bean id="Connection" class="javax.jms.Connection" factory-bean="ConnectionFactory"
    factory-method="createConnection" init-method="start" destroy-method="close" />

<bean id="QueueName" class="java.lang.String">
    <constructor-arg value="myqueue" />
</bean>

<bean id="amazonMessageListener" class="com.myapp.daemon.AsyncMessageListener" />

<bean id="messageListener"
    class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    <property name="delegate" ref="amazonMessageListener" />
    <property name="defaultListenerMethod" value="onMessage" />
    <property name="messageConverter">
        <null />
    </property>
</bean>

<bean id="jmsContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="ConnectionFactory" />
    <property name="destinationName" ref="QueueName" />
    <property name="messageListener" ref="messageListener" />
</bean>

I am having trouble understanding how to set this up in the AWS.

ElasticBeanStalk provides 2 types of environments, 1. worker and 2. webserver.

Thought the worker type environment fits the bill, according to the documentation. AWS deploys a daemon in ec2 instances, and pulls off the message from SQS and envelopes that into a message body of the http post request. This post request can be used to post to a web server.

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html#worker-environ

However the component I wrote does that. Pulls off the message from the queue, and does some background processing.

In this case which environment type should i opt?

1

1 Answers

0
votes

If you have to use worker tier you do not need to use your component and you make sure the background processing part of your application has an HTTP Post interface. You can leave polling to the daemon provided by beanstalk. I would recommend this if you want to use elasticbeanstalk.

If you want to use your component then you might as well just use web tier although if you are just doing background processing and not serving Web traffic then you will have ports listening for Web traffic, ELB for no reason.