Pages

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, June 24, 2019

Set up and develop your first Angular APP

Hello Everyone,

In this tutorial, I'm going to show you how ton set up an Angular environnement in Linux by installing NodeJS, Angular CLI and then create your first application.

to do that, we need to update our package manager


As I'm running on ubuntu, the command to install nodejs is the following : sudo apt-get install nodejs


To verify that nodeJs in installed, we can verify the version of it by typing the following command : sudo apt-get install npm






The next step is to install the node package manager, which will let us to install the required modules needed by our project.

The command to install npm is the following :
npm apt-get install npm


The next step is to install two NodeJs modules (TypeScript and Angular @CLI.) using NPM.

The commands are :
sudo npm install -g typescript
sudo npm install -g @angular/cli@1.0.0



 With those packages installed, we can verify that the Angular CLI is working properly by submitting the following command :
ng --version


to create our HelloWorld application, we can type the following:
ng new --ng6 --name hello-world


Congratulation, you've just created your first Angular application, to run it we need to enter in the created directory for our application 'hello-world' and then submit the following command :


Now that our application is running, we can access it using curl:


Friday, April 5, 2019

ActiveMQ Resource Aadapter integration with Jboss WildFly 9

I was working on a project, where we need to consume messages of ActiveMQ where the configuration is set by a Jboss WildFly 9.0.2.Final.

I'm going to show you the steps of how to setup an AtiveMQ Server, Configure a Resource Adapater in Jboss and finally how to send and consume messages through the server.

I suppose that you have a Linux environnement to do this Tutorial with docker installed, for this tutorial i used my local machine, you can use also the Amazon WS EC2.

The first Step is to start our ActiveMQ Server, to do this, type the following command in your terminal :

docker run --name='activemq' -d --rm -p 61616:61616 -p 8161:8161  webcenter/activemq:latest

This command extract the ActiveMQ Image from Docker HUB, and also it binds our local ports 61616 and 8161 to the images ports.

Now that we've our ActiveMQ Server Installed, we can access it throug the url : http://localhost:8161 with admin/admin as login/password.



For this tutorial, I'm using the ActiveMQ resource adapter version 5.13.3, you can download it through :

https://mvnrepository.com/artifact/org.apache.activemq/activemq-rar/5.13.3

Once the archive downloaded, we're going to move it the deployment directory of our Jboss Wildfly



The next step is to add ActiveMQ resource adapter to our JBOSS Widlfly.
As I'm using a JBOSS WildFly 9, we're going to edit the configuration file JBOSS_WILDFLY/standalone/configuration/standalone-full.xml

        <subsystem xmlns="urn:jboss:domain:resource-adapters:3.0">
            <resource-adapters>
                <resource-adapter id="activemq">
                    <archive>
                        activemq-rar-5.13.3.rar
                    </archive>
                    <transaction-support>XATransaction</transaction-support>
                    <config-property name="ServerUrl">
                        tcp://localhost:61616
                    </config-property>
                    <config-property name="UserName">
                        admin
                    </config-property>
                    <config-property name="UseInboundSession">
                        false
                    </config-property>
                    <config-property name="Password">
                        admin
                    </config-property>
                    <connection-definitions>
                        <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ConnectionFactory" enabled="true" pool-name="ConnectionFactory">
                            <xa-pool>
                                <min-pool-size>1</min-pool-size>
                                <max-pool-size>20</max-pool-size>
                                <prefill>false</prefill>
                                <is-same-rm-override>false</is-same-rm-override>
                            </xa-pool>
                        </connection-definition>
                    </connection-definitions>
                    <admin-objects>
                        <admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:jboss/activemq/topic/TestTopic" use-java-context="true" pool-name="TestTopic">
                            <config-property name="PhysicalName">
                                activemq/topic/TestTopic
                            </config-property>
                        </admin-object>
                        <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/TestQueue" use-java-context="true" pool-name="TestQueue">
                            <config-property name="PhysicalName">
                                activemq/queue/TestQueue
                            </config-property>
                        </admin-object>
                    </admin-objects>
                </resource-adapter>
            </resource-adapters>
        </subsystem>

At first, once we start our Jboss Server, it'll create queue named activemq/queue/TestQueue in our ActiveMQ Server.
 

Now the last step for this tutorial is our small java project that will send and consume messages through the ConnectionFactory configured in our Jboss.

First, we'll need to create our ConnectionFctory based on the JNDI name configured on the subsystem (standalone-full.xml)


Next, we'll create our destination as configured in Jboss and also à Message Container Listener that'll araise when we receive a message in the Queue.



Next we'll create our message listener


Then we need to create the rest of the components needed for the base line of our messaging communication.


Finally I created à controller that'll send the message to the ActiveMQ Server based on our configuration.



Now, as I hit the controller throught my Browser

The message is received in my Container Message Listner and the message is printed to the console.


And also we can see that our ActiveMQ Server gets and sends the messages through his queue.


You can download the while project throught : XXX

Have a nice coding ;)