<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Djordje Bajic</title>
    <description>The latest articles on DEV Community by Djordje Bajic (@djoleb).</description>
    <link>https://dev.to/djoleb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F35193%2F68678297-57a5-4074-a0d8-457ff0449c01.png</url>
      <title>DEV Community: Djordje Bajic</title>
      <link>https://dev.to/djoleb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/djoleb"/>
    <language>en</language>
    <item>
      <title>I started YT channel!</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Wed, 16 Dec 2020 22:11:47 +0000</pubDate>
      <link>https://dev.to/djoleb/java-tutorials-yt-channel-3odd</link>
      <guid>https://dev.to/djoleb/java-tutorials-yt-channel-3odd</guid>
      <description>&lt;p&gt;Hello Programmer, Developers, Administrators, DevOps people and whatever you like to be called.&lt;/p&gt;

&lt;p&gt;I started YT channel a couple of months ago.&lt;/p&gt;

&lt;p&gt;IT'S ABOUT JAVA. VERY INOVATIVE, VERY NEW, MUCH WOW, SOMETHING WORLD DID NOT SEE.&lt;/p&gt;

&lt;p&gt;Jokes aside.&lt;/p&gt;

&lt;p&gt;If you are willing, take a look, leave a comment about what should be improved, what you like...etc.&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="https://www.youtube.com/channel/UC0Ws7Fn3fTjZ9eKH87R_rKA"&gt;https://www.youtube.com/channel/UC0Ws7Fn3fTjZ9eKH87R_rKA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gimme some love, gimme some hate, whatever is on your mind.&lt;/p&gt;

&lt;p&gt;Stay safe and positive (you see what i did there),&lt;/p&gt;

&lt;p&gt;George / Djordje&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>apache</category>
      <category>camel</category>
    </item>
    <item>
      <title>Apache Camel #4 - Processors</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Thu, 03 Dec 2020 18:18:21 +0000</pubDate>
      <link>https://dev.to/djoleb/apache-camel-3-processors-55md</link>
      <guid>https://dev.to/djoleb/apache-camel-3-processors-55md</guid>
      <description>&lt;p&gt;Hello Devs!&lt;/p&gt;

&lt;p&gt;Long time no new article!&lt;/p&gt;

&lt;p&gt;Guess i have to fix that.&lt;/p&gt;

&lt;p&gt;Today we are talking about processors in Apache Camel routes.&lt;/p&gt;

&lt;p&gt;Processors are a part of camel which enables us to write our custom components and business logic and implement it in the routes.&lt;/p&gt;

&lt;p&gt;There are two ways of using processors.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating a class and implementing Processor with process method. This way we can easily write a test and separate processor logic from route itself. It looks something like this in the route.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;.process(new CustomProcessor())&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Processor itself will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class CustomProcessor implements Processor {

    @Override
    public void process(Exchange exchange) {
         exchange.getIn().setBody("test");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Functional way.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;.process(exchange -&amp;gt; exchange.getIn().setBody("test"))&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Even though this way is easier that first, it couples processor logic to route and you could only test it if you test whole route.&lt;/p&gt;

&lt;p&gt;My YT: &lt;a href="https://www.youtube.com/channel/UC0Ws7Fn3fTjZ9eKH87R_rKA"&gt;https://www.youtube.com/channel/UC0Ws7Fn3fTjZ9eKH87R_rKA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That would be all for today!&lt;br&gt;
Stay safe,stay cool!&lt;/p&gt;

&lt;p&gt;George / Djordje&lt;/p&gt;

</description>
      <category>java</category>
      <category>processors</category>
      <category>apache</category>
      <category>camel</category>
    </item>
    <item>
      <title>I wrote my first eBook!</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Sun, 15 Dec 2019 21:05:18 +0000</pubDate>
      <link>https://dev.to/djoleb/i-wrote-my-first-ebook-42g2</link>
      <guid>https://dev.to/djoleb/i-wrote-my-first-ebook-42g2</guid>
      <description>&lt;p&gt;Hello world!&lt;/p&gt;

&lt;p&gt;I am proud to announce that my ebook "How I Became a programmer" is (self) published on Amazon. This book is about my story how I got into the IT industry and what I  think beginners need to do in order to get their first programming job.&lt;/p&gt;

&lt;p&gt;If anyone is interested in reading it go to this &lt;a href="https://www.amazon.com/dp/B0813Y9VK8/"&gt;link&lt;/a&gt; and purchase it.&lt;/p&gt;

&lt;p&gt;In case that you have any questions feel free to contact me on: &lt;b&gt;&lt;a href="mailto:okand_anvandare@protonmail.com"&gt;okand_anvandare@protonmail.com&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;Djordje&lt;/p&gt;

</description>
      <category>book</category>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Apache Camel #4 - Bean Validation</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Sun, 25 Aug 2019 06:38:44 +0000</pubDate>
      <link>https://dev.to/djoleb/apache-camel-4-bean-validation-3pil</link>
      <guid>https://dev.to/djoleb/apache-camel-4-bean-validation-3pil</guid>
      <description>&lt;p&gt;There is a lot of cases where we needed to write validation for data input. This "problem" can be easily solved in Camel by using Bean Validation component.&lt;/p&gt;

&lt;p&gt;Imagine we have a JSON input in our route and we want to validate payload.&lt;/p&gt;

&lt;pre class="highlight javascript"&gt;
{
     "name":"Jane Doe",
     "cardNumber":"377198642272436",
     "email":"jane@doe.com",
     "paid":true,
     "price":1.25
}
&lt;/pre&gt;

&lt;p&gt;To do that, we first we must unmarshall that payload to POJO.&lt;br&gt;
But first, we must create a class with the same parameters as JSON and add Hibernate Validation annotations.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @NotNull
 @Length(min = 1, max = 60)
 private String name;

 @CreditCardNumber
 private String cardNumber;

 @Email
 private String email;

 @NotNull
 private boolean paid;

 @Min(0.1)
 private int price;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;And then we add this to our Camel route.&lt;/p&gt;

&lt;pre class="highlight javascript"&gt;
   //define a datasource for the class you want to validate.
   GsonDataSource dataSource = new GsonDatasource(JsonDto.class);

   //unmarshal JSON to POJO
   .unmarshall(dataSource)

   //Validate data
   .to("bean-validator:someLabelHere)
&lt;/pre&gt;

&lt;p&gt;When that unmarshalled data is sent to bean validator, that objects will be validated by annotations we set for JsonDto fields.&lt;/p&gt;

&lt;p&gt;Thank you for your attention.&lt;/p&gt;

</description>
      <category>java</category>
      <category>apache</category>
      <category>camel</category>
      <category>apachecamel</category>
    </item>
    <item>
      <title>Apache Camel #3 - RabbitMq</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Sun, 18 Aug 2019 18:58:46 +0000</pubDate>
      <link>https://dev.to/djoleb/apache-camel-3-using-rabbitmq-2250</link>
      <guid>https://dev.to/djoleb/apache-camel-3-using-rabbitmq-2250</guid>
      <description>&lt;p&gt;Hello there again!&lt;/p&gt;

&lt;p&gt;It passed 2 months since my last article, so I decided to write a new one.&lt;/p&gt;

&lt;p&gt;Today we will focus on RabbitMq and what we can do with it using Camel.&lt;/p&gt;

&lt;h3&gt;Dependencies&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://mvnrepository.com/artifact/org.apache.camel/camel-rabbitmq"&gt;Maven repository -&amp;gt; Camel RabbitMq&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Connection to RabbitMq&lt;/h3&gt;

&lt;p&gt;When using SpringBoot:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a class with @Configuration annotation.&lt;/li&gt;
&lt;li&gt;Create a method which will return ConnectionFactory and annotate it with @Bean.&lt;/li&gt;
&lt;li&gt;Instance a connection factory and set properties. &lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Bean
public ConnectionFactory rabbitConnectionFactory() {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.setHost("localhost);
    connectionFactory.setPort(5672);
    connectionFactory.setUsername("Username");
    connectionFactory.setPassword("Password);

    return connectionFactory;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;*note: You can use application properties to connect to the server. &lt;/p&gt;

&lt;p&gt;If you are using pure Camel:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DBT6tfNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zlluic9su8pvb8isxkbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DBT6tfNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zlluic9su8pvb8isxkbp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Using RabbitMq&lt;/h3&gt;

&lt;p&gt;Now that we successfully connected to RabbitMq it's time to start consuming/producing messages to queue/exchange.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://camel.apache.org/staging/components/latest/rabbitmq-component.html"&gt;Camel RabbitMq component documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consuming Message from the queue:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We will set the rabbitMq component to fetch from the queue which is bind to exchange.&lt;/li&gt;
&lt;li&gt;Log message body received.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;public void configure() {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from("rabbitmq:exchangeA?queue=QueueA&amp;amp;amp;declare=true")
.routeId("RabbiqMqConsumer")
.log("Message received: ${body}");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Producing Message to exchange:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We will create a route.&lt;/li&gt;
&lt;li&gt;Set message body.&lt;/li&gt;
&lt;li&gt;Send a message to the exchange.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;public void configure() {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; from("timer:fooo?period=10000")
 .routeId("RabbiqMqProducer)
 .setBody().constant("{\"foo\":\"bar\"}")
 .log("Message to be sent: ${body}")
 .to("rabbitmq:exchangeB");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Aand that's all folks, if anyone have some question, feel free to ask me via DM or just leave a comment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/2PuVOnv02rRvy/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/2PuVOnv02rRvy/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>rabbitmq</category>
      <category>apache</category>
      <category>camel</category>
    </item>
    <item>
      <title>Apache Camel #2 - Calling Rest API</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Thu, 30 May 2019 18:45:31 +0000</pubDate>
      <link>https://dev.to/djoleb/apache-camel-calling-rest-api-25en</link>
      <guid>https://dev.to/djoleb/apache-camel-calling-rest-api-25en</guid>
      <description>&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;This is the second text about Apache Camel, there will be a lot more in the future. Purpose of this articles is to present people the real power of Camel, maybe some of you will find a use case where you can use this framework instead of writing boilerplate code over and over.&lt;/p&gt;

&lt;p&gt;Today we will use Camel to call API endpoint and handle some of the exceptions.&lt;/p&gt;

&lt;h2&gt;Dependencies&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://mvnrepository.com/artifact/org.apache.camel/camel-http"&gt;Camel http dependency&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Routes&lt;/h2&gt;

&lt;h3&gt;Scheduler route&lt;/h3&gt;

&lt;p&gt;If you remember from &lt;a href="https://dev.to/djoleb/introduction-to-apache-camel-7m9"&gt;introduction&lt;/a&gt;, this is a scheduler route, it will trigger a message every 120 seconds and send it to "direct:httpRoute" route. I am using synchronous &lt;a href="https://camel.apache.org/direct.html"&gt;"direct"&lt;/a&gt; component, there is also asynchronous &lt;a href="https://camel.apache.org/seda.html"&gt;"seda"&lt;/a&gt; component.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Override"
public void configure() {

    from("timer:scheduler?period=120000")
            .log("Scheduled job!")
            .to("direct:httpRoute");

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;Http route&lt;/h3&gt;

&lt;p&gt;This is a HTTP client route, it will call the bittrex rest API and get crypto currencies and log the response.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Override
public void configure() {

    from("direct:httpRoute")
            .log("Http Route started")
            .setHeader(Exchange.HTTP_METHOD).constant(HttpMethod.GET)
            .to("https://api.bittrex.com/api/v1.1/public/getcurrencies")
            .log("Response : ${body}");

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;Error Handlers&lt;/h3&gt;

&lt;p&gt;If you want to cover some exceptions there is a two options.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Default error handler&lt;/li&gt;
&lt;li&gt;onException clause to handle specific class exceptions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;@Override&lt;br&gt;
    public void configure() {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    errorHandler(deadLetterChannel("mock:errorHandler"));

    onException(HttpOperationFailedException.class)
            .log("${exception}")
            .to("mock:errorHandler");

    from("direct:httpRoute")
            .log("Http Route started")
            .setHeader(Exchange.HTTP_METHOD).constant(HttpMethod.GET)
            .to("https://api.bittrex.com/api/v1.1/public/getcurrencies")
            .log("Response : ${body}");

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;Results&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--olAvdR2D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r2d94dl7rfecuqyqhn2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--olAvdR2D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r2d94dl7rfecuqyqhn2i.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is all for this tutorial, if something is not clear, feel free to contact me I will gladly answer any question.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>apachecamel</category>
      <category>java</category>
      <category>rest</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How many developers are musicians?</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Sun, 26 May 2019 09:20:35 +0000</pubDate>
      <link>https://dev.to/djoleb/how-many-developers-are-musicians-3khi</link>
      <guid>https://dev.to/djoleb/how-many-developers-are-musicians-3khi</guid>
      <description>&lt;p&gt;Hey!&lt;/p&gt;

&lt;p&gt;How many of you play an instrument?&lt;br&gt;
Do you play in a band?&lt;/p&gt;

&lt;p&gt;if (you do) {&lt;br&gt;
   please leave a comment with a link to your music.&lt;br&gt;
} else {&lt;br&gt;
   listen to music from comments!&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;This way I want to learn more about bands you guys play in, maybe some of that music will be on my playlist in the future.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>hobbies</category>
      <category>creativity</category>
      <category>music</category>
    </item>
    <item>
      <title>Apache Camel #1 - Introduction to Apache Camel</title>
      <dc:creator>Djordje Bajic</dc:creator>
      <pubDate>Sat, 25 May 2019 15:27:22 +0000</pubDate>
      <link>https://dev.to/djoleb/introduction-to-apache-camel-7m9</link>
      <guid>https://dev.to/djoleb/introduction-to-apache-camel-7m9</guid>
      <description>&lt;p&gt;Hello World!&lt;/p&gt;

&lt;p&gt;This is my first post so I decided to write about the framework I use a lot in the last couple of months.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Apache Camel&lt;/b&gt; is a very powerful integration framework, it is used as a mediation engine between two systems, it has a great community, large codebase with over 200 &lt;a href="http://camel.apache.org/component-list.html"&gt;components&lt;/a&gt; which can be used out of the box and of course it is written in Java.&lt;/p&gt;

&lt;p&gt;On project &lt;a href="http://camel.apache.org/"&gt;official website&lt;/a&gt; you can find documentation and all info about releases.&lt;/p&gt;

&lt;h2&gt;Camel Context&lt;/h2&gt;

&lt;p&gt;Context is a heart of camel applications and it represents runtime system.&lt;/p&gt;

&lt;h2&gt;Camel Route&lt;/h2&gt;

&lt;p&gt;Sample route:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vhdJtYLl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/83icy3metd39k0agqj1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vhdJtYLl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/83icy3metd39k0agqj1h.png" width="518" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explanation: &lt;/p&gt;

&lt;p&gt;As you probably noticed class Route extends the RouteBuilder class, from which you will override configuration and write your route in it.&lt;/p&gt;

&lt;p&gt;I used JavaDsl in this route, you can use any other &lt;a href=""&gt;dsl&lt;/a&gt; that camel supports. &lt;/p&gt;

&lt;p&gt;errorHandler(deadLetterChannel("mock:errorRoute")) - This is error handler for this particular route, if any exception occurs message will be sent to deadletter mock queue "errorRoute".&lt;/p&gt;

&lt;p&gt;from("timer:timerName?period=5000") - "from" is like an endpoint in camel context. In this particular case, it is timer component(scheduler) which will trigger route execution every 5 seconds, timer name is "timerName". You can check more about that on this &lt;a href="https://camel.apache.org/from.html"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;log("Route started!") - this is a camel's log component which will print text in console.&lt;/p&gt;

&lt;p&gt;to("mock:anotherRouter") - "to" represents on which endpoint, queue or route message will be sent. "mock:anotherRoute" represents a mock queue on which message will be sent.&lt;/p&gt;

&lt;p&gt;These are the most basic things about Camel.&lt;/p&gt;

&lt;p&gt;If you are interested in learning a little more about Apache Camel feel free to contact me here or on gitter -&amp;gt; &lt;a class="mentioned-user" href="https://dev.to/djoleb"&gt;@djoleb&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>java</category>
      <category>apache</category>
      <category>camel</category>
      <category>apachecamel</category>
    </item>
  </channel>
</rss>
