<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dan Erez on Medium]]></title>
        <description><![CDATA[Stories by Dan Erez on Medium]]></description>
        <link>https://medium.com/@dan.erez?source=rss-ea05b98dc820------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DFRKmb_SJzi-7M4PQEWr1w.jpeg</url>
            <title>Stories by Dan Erez on Medium</title>
            <link>https://medium.com/@dan.erez?source=rss-ea05b98dc820------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:01:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dan.erez/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I MCPed My Lawyer]]></title>
            <link>https://medium.com/@dan.erez/how-i-mcped-my-lawyer-a8156b9e6248?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8156b9e6248</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 09:32:27 GMT</pubDate>
            <atom:updated>2025-08-10T09:32:27.680Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Using Model Context Protocols to Supercharge Legal Workflows</em></p><h3><strong>What is MCP (Model Context Protocol)?</strong></h3><p><strong>MCP</strong>, or <em>Model Context Protocol</em>, is a structured method for supplying large language models (LLMs) with the right task-specific information at the right time. Instead of relying on ambiguous instructions or overly generic prompts, MCP helps the LLM to retrieve the exact information needed. This information can come from:</p><ul><li>‘Standard’ API calls</li><li>Directly querying a database</li><li>Documents and other resources retrieval</li></ul><p>MCPs can also perform operations, not just retrieve data. For example they can send emails, operate browsers, write databases, etc.</p><p>You can think about MCPs as ‘API for LLMs’ though they are much more than that.</p><p><strong>Diagram: MCP Overview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*Q_X41Pwu3iaxwbsV" /></figure><p>It’s hard to make predictions (especially about the future ;) ) but it seems that LLMs and MCP based systems will replace many of the classical applications that are developed today. Currently, a large portion of the applications developed in many IT organizations is a classical web frontend — code backend — database.</p><p>But instead of actually coding all possible queries, and pre-create all the needed screens and UI components, why not generate them on the fly? It is cheaper, faster to implement and much, much more flexible. When a business need arises, just ask your LLM for an answer. Since it is connected to the database, it can easily conjure the suitable SQL for retrieving (or updating) the needed information and run it via our beloved MCP. Need a UI? No problem, it can also generate the proper UI (via MCP-UI or as HTML to embed in the web page) and that’s it. You can of course cache the query, the UI or both for faster future use but that’s all you need for a know-it-all business application without writing another line of code!</p><h3><strong>RAG, Text to SQL and other ways to retrieve data</strong></h3><p>It might seem odd when you think about it, but querying <strong>unstructured </strong>text via an LLM is not a very hard task, and it has been researched a lot. For example, you can:</p><ol><li>For small datasets, add the entire dataset to the prompt and ask about it</li><li>For larger datasets, use one of the many existing RAG methods to add the most query-relevant data to the prompt</li><li>If push comes to shove, you can always fine-tune an existing model to learn your specific data</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/0*VQd2gYKXylZPzqSg" /><figcaption>RAG me, baby!</figcaption></figure><p>Dropping a large set of structured or relational data into an LLM context likely won’t work well, for various reasons. For example:</p><ol><li>An LLM is natural language affine, and treating relational, row based information as a chunk of text is, well, wrong and will result in inaccurate responses</li><li>It will not apply SQL queries to the data, so there is no guarantee of accurate, fast result</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*PvOsNQZ3k2tBEJ08" /><figcaption>Don’t get relational on me!</figcaption></figure><p>But don’t despair! There are (at least) two possible methods that WILL provide good and accurate results when querying for structured data. Let’s take a look at the options:</p><p>Your first option: MCP (Model Context Protocol) it (of course)!</p><p>If you can have an MCP to call anything, then you definitely can have an MCP for working with databases. A few examples (there are many, many more):</p><ul><li>Supabase MCP (https://github.com/supabase-community/supabase-mcp)</li><li>PostgreSql MCP (https://github.com/crystaldba/postgres-mcp)</li><li>SQL Server MCP (https://devblogs.microsoft.com/azure-sql/introducing-mssql-mcp-server/)</li></ul><p>Using such MCPs will allow the LLM to actually execute any SQL query it can conjure, and even correct faulty queries when needed. Sweet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*uRN9juoUm6YQsvx6" /><figcaption>Acessing a DB using an MCP</figcaption></figure><p>In this option all you have to do is configure the MCP, for example (In Claude Desktop):</p><pre>&quot;mcpServers&quot;: {<br>&quot;supabase&quot;: {<br>&quot;command&quot;: &quot;cmd&quot;,<br> &quot;args&quot;: [<br>  &quot;/c&quot;,<br>  &quot;npx&quot;,<br>  &quot;-y&quot;,<br>  &quot;@supabase/mcp-server-supabase@latest&quot;,<br>  &quot; - access-token&quot;, &quot;&lt;&lt; Your access token &gt;&gt;&quot;<br> ]<br> },<br>}</pre><p>When you’re using an API, like Claude’s, you can pass it along with the API request:</p><pre>const response = await anthropic.beta.messages.create({<br>model: &quot;claude-sonnet-4–20250514&quot;,<br>max_tokens: 10000,<br>system: systemPrompt,<br>messages: [<br>{<br>  role: &quot;user&quot;,  content: message<br>}],<br>mcp_servers: [<br>{<br> type: &quot;url&quot;,<br> url: &quot;https://server.smithery.ai/@supabase-community/supabase-mcp/mcp?api_key=&lt;&lt; Your API Key &gt;&gt;&quot;,<br> name: &quot;supabase&quot;<br>}],<br>betas: [<br>&quot;mcp-client-2025–04–04&quot;<br>]});</pre><p>Your second option: Run the SQL yourself</p><p>The second approach does not rely on MCP, but on your own code (solely, or with some agent management library), so <strong>you </strong>control the flow. So it goes like this:</p><ul><li>You present the top problem to the LLM, and ask for a suitable SQL for it</li><li>The LLMcreates the desired SQL</li><li>You run the query against your favourite database and collect the response</li><li>You pass the LLM the top question along with the response rows and asks for the final answer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/0*rw-eIFANP6PFohBD" /><figcaption>Doing it yourself</figcaption></figure><p>Wait, so what’s the difference?</p><p>At first glance, you probably think — why work hard and manage the process yourself when you can instead just configure the desired MCP server and let the LLM do all the hard work?</p><p>Well, since I did exactly that in a simple use case and got great results — that was my first approach. Alas, things did not go so smoothly in the second use case. I noticed:</p><ul><li>The LLM issued multiple SQL queries (where it could have joined tables)</li><li>Many rows were returned, thus overloading the context (and the cost)</li><li>The LLM did not recognize well questions it could not really answer with the available data, thus misleading the user with incorrect answers</li></ul><p>The causes were clear. In this use case:</p><ul><li>There was more data in the tables and more tables/columns</li><li>The system was meant to be available to many users and not just me, so the range of questions can be, well, infinite (even if there is no suitable info in the DB)</li></ul><p>Obviously the LLM (Claude, in this case) didn’t infer Spiderman, as I gave it the power (MCP) but it ditched the responsibility… Oh well.</p><p>Hence I experimented with the second approach — I removed the MCP, and acted as the responsible adult that sits between the LLM and the database:</p><ul><li>I asked the LLM for an SQL query that answers the question (and verified it could answer the question)</li><li>I made sure the SQL would not return too many rows (by limiting the returned number of rows, if the LLM hasn’t done so)</li><li>I asked the LLM to verify the SQL, making sure it joined all the needed tables to avoid additional queries</li><li>I ran the SQL against the database, and passed the results back to the LLM, demanding an answer to the user’s main question</li></ul><p>This improved things. Of course I couldn’t get answers for questions about data I didn’t have, but now I had some control over the queries, result tuning and whether or not I should use the generated queries. Plus, adding cache to the system was much easier and didn’t require the good will of the LLM. I was able to cache the SQL queries and their answers and even manage a (human language) query cache to ask the LLM if a new question is semantically equivalent (still not perfect, but promising).</p><p><strong>Summary</strong></p><p>Let’s summarize the main differences between the MCP based approach and the more agentic one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xk5riUv2QWKIKlDG.png" /><figcaption>Let’s compare!</figcaption></figure><p>One additional, extremely important aspect is security. When working with MCP directly, the LLM can issue any query it desires and will only be limited by the database permissions of the user. With the second option, you get to review, check, and manipulate the SQL yourself. So, if sensitive data might be at risk, take precautions.</p><p>What should you choose? As you can see, it depends — in the simple, more ‘closed’ cases the direct MCP approach will work well and save you development effort. Otherwise, at least until the models are even better — you’ll have to assist with directions, checks, caching, etc. So the self orchestrating approach will be needed.</p><h3><strong>Why Lawyers Need This: Document Analysis, Lawsuit Drafting, and More</strong></h3><p>Legal professionals handle massive volumes of complex information. To function effectively, a lawyer must:</p><ul><li>Analyze legal documents, contracts, and case law</li><li>Draft lawsuits, defenses, and motions</li><li>Reference rulings, statutes, and procedural norms</li></ul><p>This requires <strong>time,</strong> <strong>precision, structure, and memory</strong>. Legal work isn’t just about writing well — it’s about fitting arguments into a strict system. Without automation, these workflows are slow and prone to oversight.</p><p>MCP can change the game by offloading the <strong>document-heavy, repeatable work</strong>, letting lawyers focus on strategy. The ability of cutting-edge LLMs to understand text, use context efficiently and now use MCP servers enables us to write a system for Lawyers that actually makes a difference and enables the lawyer to be a “10x Lawyer”.</p><p>In the following example, in order to perform the task of writing a defence statement for a lawsuit, the LM will use MCPs to:</p><ol><li>Check similar lawsuits for details (defenses, outcome)</li><li>Check the law for possible defences</li><li>Check historical defenses written by this lawyer in order to apply a similar approach for this case</li></ol><p><strong>Diagram: Legal Work and Contextual Assistance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*Q9dlzXSWOObJJW54" /></figure><h3><strong>First MCP: Searching in a Rulings Database</strong></h3><p>The first MCP I built was for <strong>retrieving legal precedent</strong>. Our lawyer needed to locate past rulings quickly and accurately. Since this is a simple and well defined database I took the MCP approach (instead of asking the LLM to generate SQL and run it myself).</p><p><strong>What It Did:</strong></p><ul><li>Allow the search of similar lawsuits by keywords and dates</li><li>Allow the search of a specific lawsuit by case no.</li><li>Allow the search of lawsuits by the plaintiff or the judge</li></ul><p><strong>What Made It Work:</strong></p><ul><li>The ability to call historical lawsuits database</li><li>Defining proper prompt templates</li><li>Providing the MCP with a suitable list of keywords (for the first tool)</li></ul><p><strong>Diagram: Rulings Search MCP Flow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DUzwtH_hBZ9KfZ9K" /></figure><h3><strong>Second MCP: The Lawyer’s Standards and Templates</strong></h3><p>Next, I created an MCP to align the model’s output with our <strong>firm’s internal formatting and legal style</strong> — based on historical defence statements and templates.</p><p><strong>What It Did:</strong></p><ul><li>Loaded example filings to learn tone and structure</li><li>Parsed templates: lawsuits, motions, defenses</li><li>Included jurisdictional and formatting standards</li></ul><p><strong>Diagram: Standards MCP Components</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yOrgXC5DQJEOtzGY" /></figure><h3><strong>Putting It All Together</strong></h3><p>That is the first phase of a complete system to aid lawyers and law firms. The functionality is still limited but the users can now get a decent defense statement that addresses the lawsuit, based on existing rulings and formatted according to company standards.</p><p>Even at that first phase, lawyers get great value from this system, as it:</p><ol><li>Save a lot of time, since manual searches are not longer needed</li><li>Produce a more accurate results than human writing in natural language</li><li>Keeps improving, as more information is added to the databases over time</li></ol><h3><strong>Future Improvements</strong></h3><p>Additional capabilities that will be added in the following months to make the system complete:</p><ol><li>The option to draft lawsuits, based on some guiding lines as an input, plus looking at previous lawsuits created by the lawyer (for similarity).</li><li>The ability to issue letters (e.g. warning letters) to the parties, as part of a predefined process (by using some BPM system like Camunda or Temporal).</li><li>An agent to manage the entire process and act as an intern — handle all paperwork and documents, act according to feedback, monitor the process, etc.</li></ol><h3><strong>Final Thoughts</strong></h3><p>MCPs are a real revolution, and it is already here. In systems that are text rich, repetitive, have some structure and a lot of examples (as it is for a law firm) the combination of LLMs and MCPs can shine and provide a lot of value by saving time and money. This is just the beginning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8156b9e6248" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Structured Data with LLMs]]></title>
            <link>https://medium.com/@dan.erez/using-structured-data-with-llms-ee5c5d983b85?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee5c5d983b85</guid>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 05:53:09 GMT</pubDate>
            <atom:updated>2025-08-05T07:22:43.753Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Intro</strong></h3><p>Recently, a friend asked for my help — he had data from some relational tables, and he wanted to query this data in a natural language, via an LLM like ChatGPT or Claude.</p><p>It might seem odd when you think about it, but querying <strong>unstructured </strong>text via an LLM is not a very hard task, and it has been researched a lot. For example, you can:</p><ol><li>For small datasets, add the entire dataset to the prompt and ask about it</li><li>For larger datasets, use one of the many existing RAG methods to add the most query-relevant data to the prompt</li><li>If push comes to shove, you can always fine-tune an existing model to learn your specific data</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/0*lNoJWR5E2Vm8tSFP" /><figcaption>Image 1: The RAG process</figcaption></figure><p>Dropping a large set of structured or relational data into an LLM context likely won’t work well, for various reasons. For example:</p><ol><li>An LLM is natural language affine, and treating relational, row based information as a chunk of text is, well, wrong and will result in inaccurate responses</li><li>It will not apply SQL queries to the data, so there is no guarantee of accurate, fast result</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*uRkVjMZB0BBOthAu" /><figcaption>Image 2: LLMs and large relational data</figcaption></figure><p>But don’t despair! There are (at least) two possible methods that WILL provide good and accurate results when querying for structured data. Let’s take a look at the options:</p><h3><strong>Your first option: MCP (Model Context Protocol) it!</strong></h3><p>Nowadays you can’t walk around LLMs without stepping on an MCP or two. If you’ve just returned from a family trip to Mars, I’ll quickly explain that MCP is a protocol that allows LLMs to make calls to, well, anything. Think of it as an API for LLMs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/0*7vyrO_ImE9peaDRn" /><figcaption>Image 3: Using an MCP</figcaption></figure><p>If you can have an MCP to call anything, then you definitely can have an MCP for working with databases. A few examples (there are many, many more):</p><ul><li>Supabase MCP (https://github.com/supabase-community/supabase-mcp)</li><li>PostgreSql MCP (https://github.com/crystaldba/postgres-mcp)</li><li>SQL Server MCP (https://devblogs.microsoft.com/azure-sql/introducing-mssql-mcp-server/)</li></ul><p>Using such MCPs will allow the LLM to actually execute any SQL query it can conjure, and even correct faulty queries when needed. Sweet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*nhGE7fy0aLsqWKqN" /><figcaption>Image 4: Accessing a DB using an MCP</figcaption></figure><p>In this option all you have to do is configure the MCP, for example (In Claude Desktop):</p><pre>&quot;mcpServers&quot;: {<br> &quot;supabase&quot;: {<br> &quot;command&quot;: &quot;cmd&quot;,<br> &quot;args&quot;: [&quot;/c&quot;,&quot;npx&quot;,&quot;-y&quot;,&quot;@supabase/mcp-server-supabase@latest&quot;,<br> &quot; - access-token&quot;,<br> &quot;&lt;&lt; Your access token &gt;&gt;&quot;]<br>}, }</pre><p>When you’re using an API, like Claude’s, you can pass it along with the API request:</p><pre>const response = await anthropic.beta.messages.create({<br>  model: &quot;claude-sonnet-4–20250514&quot;,<br>  max_tokens: 10000,<br>  system: systemPrompt,<br>  messages: [ { role: &quot;user&quot;, content: message } ],<br>  mcp_servers: [ { type: &quot;url&quot;,<br>      url: &quot;https://server.smithery.ai/@supabase-community/supabase-mcp/mcp?api_key=&lt;&lt; Your API Key &gt;&gt;&quot;,<br>      name: &quot;supabase&quot;<br>} ], betas: [ &quot;mcp-client-2025–04–04&quot; ] });</pre><h3>Your second option: Run the SQL yourself</h3><p>The second approach does not rely on MCP, but on your own code (solely, or with some agent management library), so <strong>you </strong>control the flow. So it goes like this:</p><ul><li>You present the top problem to the LLM, and ask for a suitable SQL for it</li><li>The LLM creates the desired SQL</li><li>You run the query against your favourite database and collect the response</li><li>You pass the LLM the top question along with the response rows and asks for the final answer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/0*YnKYNflu5stYneKb" /><figcaption>Image 5: Doing it yourself</figcaption></figure><h3>So… what’s the difference?</h3><p>At first glance, you probably think — why work hard and manage the process yourself when you can instead just configure the desired MCP server and let the LLM do all the hard work?</p><p>Well, since I did exactly that in a simple use case and got great results — that was my first approach. Alas, things did not go so smoothly in the second use case. I noticed:</p><ul><li>The LLM issued multiple SQL queries (where it could have joined tables)</li><li>Many rows were returned, thus overloading the context (and the cost)</li><li>The LLM did not recognize well questions it could not really answer with the available data, thus misleading the user with incorrect answers</li></ul><p>The causes were clear. In this use case:</p><ul><li>There was more data in the tables and more tables/columns</li><li>The system was meant to be available to many users and not just me, so the range of questions can be, well, infinite (even if there is no suitable info in the DB)</li></ul><p>Obviously the LLM (Claude, in this case) didn’t infer Spiderman, as I gave it the power (MCP) but it ditched the responsibility… Oh well.</p><p>Hence I experimented with the second approach — I removed the MCP, and acted as the responsible adult that sits between the LLM and the database:</p><ul><li>I asked the LLM for an SQL query that answers the question (and verified it could answer the question)</li><li>I made sure the SQL would not return too many rows (by limiting the returned number of rows, if the LLM hasn’t done so)</li><li>I asked the LLM to verify the SQL, making sure it joined all the needed tables to avoid additional queries</li><li>I ran the SQL against the database, and passed the results back to the LLM, demanding an answer to the user’s main question</li></ul><p>This improved things. Of course I couldn’t get answers for questions about data I didn’t have, but now I had some control over the queries, result tuning and whether or not I should use the generated queries. Plus, adding cache to the system was much easier and didn’t require the good will of the LLM. I was able to cache the SQL queries and their answers and even manage a (human language) query cache to ask the LLM if a new question is semantically equivalent (still not perfect, but promising).</p><h3>Summary</h3><p>Let’s summarize the main differences between the MCP based approach and the more agentic one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY9NOAQ9gaXmq23MzKPc8Q.png" /><figcaption>Image 6: Let’s compare!</figcaption></figure><p>One additional, extremely important aspect is security. When working with MCP directly, the LLM can issue any query it desires and will only be limited by the database permissions of the user. With the second option, you get to review, check, and manipulate the SQL yourself. So, if sensitive data might be at risk, take precautions.</p><p>What should you choose? As you can see, it depends — in the simple, more ‘closed’ cases the direct MCP approach will work well and save you development effort. Otherwise, at least until the models are even better — you’ll have to assist with directions, checks, caching, etc. So the self orchestrating approach will be needed.</p><p>Happy querying!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee5c5d983b85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP have just killed programming (and DevOps, and RAG…)]]></title>
            <link>https://medium.com/@dan.erez/mcp-have-just-killed-programming-and-devops-and-rag-9e38d7e3ae10?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e38d7e3ae10</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Thu, 15 May 2025 23:43:48 GMT</pubDate>
            <atom:updated>2025-05-15T23:43:48.644Z</atom:updated>
            <content:encoded><![CDATA[<p>The future arrived not with a bang, but with a quiet, modest protocol. The <strong>Model Context Protocol (MCP)</strong> has started in a new era of software development — one in which large language models (LLMs) don’t just assist human developers but <em>replace</em> them in many roles. This isn’t a distant dystopia. It’s happening now.</p><p>In this article, I’ll review what the MCP is, how it works, the implications for human developers, and — most importantly — what you can do to adapt, thrive, and stay relevant in a world where code is increasingly written by machines.</p><h3><strong>What Is MCP (Model Context Protocol)?</strong></h3><p>The <strong>Model Context Protocol</strong>, or MCP, is a communication and orchestration layer that allows large language models to interact with APIs, services, resources and, well, anything. Think of it as <strong>an API for LLMs</strong> — an interface between the LLMs and the execution environments (e.g., runtimes, databases, APIs, systems).</p><p>MCP implementation is divided to two components– a client and a server. The client resides with a host, that is the application that operates the LLM (e.g., Claude Desktop) and communicates with the server. The server, on the other hand, communicates with the resource below — calls APIs, query databases, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*avUxHk7G8_WPnsv3Kbu1pw.jpeg" /><figcaption>MCP is here!</figcaption></figure><h3><strong>Examples of MCP servers</strong></h3><p>Some examples of MCP servers that are available (there are already thousands of them out there):</p><p><strong>1. Github MCP</strong></p><p>Manipulate your repository any way you like — create PRs, resolve them, pull files. In short, all that you need from a GIT repository.</p><p><strong>2. Supabase and PostgreSql MCPs</strong></p><p>With DB related MCPs you can run queries, insert rows and many other DB actions.</p><p><strong>3. Automation MCP</strong></p><p>Control agents like Playwright, Selenium and Puppeteer to run your automation tests, browser related tasks, etc.</p><p><strong>4. In-house Enterprise MCPs</strong></p><p>It’s quite easy to write your own MCP servers that expose tools to perform business tasks. For example, if you’re an airline you can publish (internally or publicly) an MCP server that support buying tickets, query existing orders, etc.</p><h3><strong>Wait, LLMs could call tools before, why is this different?</strong></h3><p>True, many LLMs had the option to call tools, but there are a few major differences:</p><ol><li>Using tools was cumbersome and nonstandard. This is what you had to do yourself:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*GsDtjN547j24s6yFj1Px-w.jpeg" /><figcaption>Life before MCP</figcaption></figure><p>Straightforward, right? Not really… In each call you had to tell the LLM about the tools, get suggestion to call them. Call them yourself, pass the results and only then get the final response. A headache. Not anymore! Now it is simple and standard — see no. 2…</p><p>2. Standardizations caused an EXPLOSION of MCP servers. You can now do anything you want with them. You can now use an MCP to make you coffee. It is so easy to create MCP servers that my grandmother is now writing two before breakfast.</p><p>To summarize, MCP servers do not make LLMs smarter, they make them more capable. Think about a very smart guy that can’t move his arms and legs (and maybe even has a voice synthesizer…). That guy knows everything, but he can’t really DO anything, he can just talk about it. Well now he’s got bionic arms and legs (and even wings) that turned him into superman!</p><h3><strong>No more writing applications</strong></h3><p>Many of the applications out there have some common features — You have some UI that lets the users perform business operations that translate to read and write operations on the DB. There are also many offline applications that deals with data — transform it, enrich it, store it elsewhere etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*gIE6dr3lK14Th2iLw2PRjw.jpeg" /><figcaption>Your Typical Web Application</figcaption></figure><p>But when an LLM that understands your data can go straight to your database, it is much easier to ask it ‘give me the details of the 10 best salespersons in the company in JSON format’. With some good context about the data tables, it can produce perfect results. Oh, JSON is not good enough for you? No problem. Have you heard about Generative UI? It’s about asking LLMs to generate a custom user interface according to the data at hand, the user, etc. So, no need to build complicated UI, data access layers, heavy frameworks and even servers! Need to add a customer? An adequate form will be generated for you according to the Customers DB table and some company rules. Want to see a dashboard with all sorts of tables and graph that tells you everything about sales? It will be tailored and generated for you immediately. That’s it! No more coding!</p><p>This also means no more DevOps (sorry guys!). When the model understands your project, it also knows how to generate a deployment for it (include Nginx, Databases, company standards, etc.) and, using MCP of course, even deploy it to your favorite cluster.</p><h3><strong>OK… but why did it kill RAG?</strong></h3><p>RAG became a common technique for enriching our prompt with relevant context. For this to happen, you need to load all of the potentially useful data from all the data sources, create embeddings, store them in a vector database, and at runtime query the vector database for the relevant info. Even after all that there is no guarantee that you retrieved a relevant context. To add to your pain, you also can’t know if you added too much context (thus confusing the LLM) or too little (thus denying the LLM from useful information). Life is hard…</p><p>Not anymore! With the proper MCPs the LLM can query for relevant data on its own. It knows better than you about its missing data and if you MCPed the relevant data sources it can now query them independently until it has all the relevant information. No more vector databases and embeddings, let the LLM do the hard work (that’s why we pay them those 20$ 😉 ).</p><h3><strong>What’s still missing?</strong></h3><p>Just to be fair, this war is not <strong>entirely</strong> over. There are still a few issues that needs to be fixed (and will probably be fixed in the coming months) for things to work smoothly. For example:</p><p>1. Accuracy issues — When you let an LLM touch your database via MCPs, things can go south: Databases can be deleted, tickets can contain irrelevant descriptions etc.</p><p>2. Security issues — When you connect a 3rd party MCPs to organizational data, you take a risk. Same risk as using a 3rd library in your code without scanning it.</p><p>As models gets better, and the industry matures to create tools for safer MCP usage these childhood illnesses will be gone and MCPs will be used by larger companies and enterprises.</p><p><strong>What Can Humans Do About It</strong></p><p>Although I think MCPs as the death knell of human software development — it is only true if we refuse to evolve (After all, we’ve already won the evolution game once…). There <em>is</em> a path forward for developers, designers, and architects (And I don’t mean having a tenured position). Here’s how to stay relevant:</p><p><strong>1. Move Up the Abstraction Stack</strong></p><p>Forget about writing code (or do it at home when nobody sees you). Humans should focus on high-level product thinking, architectural intent, ethical design, and user empathy — areas where LLMs still lag. LLMs can already write code better than you — would you try to outrun a car?</p><p><strong>2. Become an LLM operator and MCP Collaborator</strong></p><p>Learn how to get better results from LLMs and MCPs. Be a better prompter. Develop mechanisms (like Cline’s memory bank, for example) that make LLMs and MCPs work better. Create your own MCPs and agents and master that art.</p><p><strong>3. Specialize in Guardrails</strong></p><p>As LLMs write code, humans must define and enforce constraints: security policies, compliance rules, quality standards, and ethical boundaries. These are the invisible hands that shape responsible AI-driven software.</p><p><strong>4. Master Multi-Agent Systems</strong></p><p>Tomorrow’s software will be written by swarms of collaborating agents. Knowing how to coordinate, monitor, and evaluate these systems will be crucial.</p><p><strong>5. Invest in Human Touchpoints</strong></p><p>LLMs don’t understand humans the way humans do. The ability to write compelling UX copy, craft delightful interactions, and interpret ambiguous stakeholder needs will always be valuable.</p><p>So don’t retire just yet!</p><h3><strong>Conclusion</strong></h3><p>LLMs and MCPs haven’t just changed software development — they have <strong>redefined</strong> it. Human coding is no longer required. Instead, you will work with LLMs, Agents and MCPs, managing the process to make everything run safely and smoothly.</p><p>This shift doesn’t spell doom — it signals opportunity. The rules are changing. If you can adapt, you can lead. Good luck.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e38d7e3ae10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NoOps is finally here!]]></title>
            <link>https://medium.com/@dan.erez/noops-is-finally-here-a834a8505617?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/a834a8505617</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[noops]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Wed, 05 Mar 2025 16:11:45 GMT</pubDate>
            <atom:updated>2025-03-05T17:21:40.645Z</atom:updated>
            <content:encoded><![CDATA[<p>DevOps has rapidly evolved in the last decade, fueled by the wide adoption of cloud services along with agile methodologies and CI/CD. Who doesn’t want to continuously deliver and deploy to cool cloud services, enjoying infinite scalability and zero downtime? DevOps teams work hard to provide that, crafting poetic YAML files that deploy everything in harmony, and on time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*XEH0D_ElrhWNNN0w" /><figcaption>Image 1 — The DevOps Cycle</figcaption></figure><p>The situation described above is indeed heartwarming, but it also has its drawbacks, especially for developers and development managers. When you think about the current software release pipeline you can see that:</p><ol><li>You need DevOps engineers — Good ones are hard to find and they cost a lot (sometimes more than developers).</li><li>They are the bottleneck for deployments — when developers are dependent on DevOps engineers and cannot deploy their own applications, you slow down.</li><li>Things get complicated over time — Systems, and therefore deployments, are almost always getting more complicated, not less. This means you need more costly DevOps engineers and developers to wait more for deployments or help.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/0*7sHz8iDzvrwPhYw7" /><figcaption>Image 2 — A manager after receiving the cloud bill</figcaption></figure><p>So, what can you do about it? One possible solution is teaching developers how to write deployment scripts. After all, the ruling paradigm these days is “Infrastructure As Code” and developers can write code, right?</p><p>Well, yes and no. Experienced developers can learn how to write Kubernetes YAML files and maybe even do it well, but writing deployments configuration is NOT like writing code — you basically define the running environment of your application, so you need to know about resources, server types, Kubernetes, network, security and much more. In other words, you’d ask your developers to become DevOps engineers as well. This is not an easy task, and it also means that they will do less software development, as one comes at the expense of the other. C’est la vie!</p><p>Another approach would be to simplify things. Today there are many options for simple deployments. Take Render (<a href="https://www.render.com/">https://www.render.com</a>) for example — place your application in a docker container, push it to a registry and in one click you can have it up and running and accessible by everyone — and it’s even free (at least until you’ll need more resources for it). But, although this is great for small applications that can fit into a container, things get more complicated when you need more moving parts in your system — multiple services, safe networking, various databases, blob storage and many other parts that compose medium to large scale applications. Back to square one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Dy1eHb4JJZ1kSLG" /><figcaption>Image 3 — A sample architecture for an application for AWS, Simplified.</figcaption></figure><p>But what if we’d look at this problem from a totally different angle? What if we could eliminate the need for anyone to write deployment files? What if they could be generated automatically?</p><p>Well, I think they can, and it’s not even that complicated!</p><p>When you think about it, if the deployment configuration is created to serve and run a specific application then the application holds all or most of the needed information for this deployment. Makes sense, no?</p><p>There are other tools in this domain, but none of them goes the full way, for example:</p><ul><li>Ampt — JavaScript deployments</li><li>Encore — typescript backend SAAS</li><li>Shuttle — Backend SAAS</li><li>Modal — AI Infra in the cloud</li><li>Nitric — Infra IN code</li><li>Klotho — Terraform on steroids</li></ul><p>Let’s say, for example, that we have a single Spring Boot application. We can directly deduce much of the needed infrastructure and resources for it, for example:</p><ul><li>If the application is using a database (and its type) there should be properties indicating that, such as the connection string, dialect info, etc. Also, the database JAR files will be present in the POM file of the application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*fLo0ZpVoLbclVybL" /><figcaption>Image 4: Sample DB definition in Spring’s properties file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*GeRe9LaRLLCZX5JC" /><figcaption>Image 5: Hints from the POM</figcaption></figure><ul><li>If this is a web application, the proper dependencies will be in the POM. The main port of the application (server.port) will be present in the configuration. Also, all the paths for the exposed REST APIs can be collected from the Controllers’ content.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/0*fgDMdA6le_AUYT4-" /><figcaption>Image 6: So… you want to run a web application, eh?</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*2DS8wUSQPxvhW9FN" /><figcaption>Image 7: The path of the righteous</figcaption></figure><p>Even from these two simple examples we can say a lot about the needed deployment, so we can:</p><ol><li>Define a docker container for this service</li><li>Create a database resource (let’s say PostgreSQL)</li><li>Ensure that the service can access the database (same subnet, for example)</li><li>Create an API gateway and map the collected routes</li><li>Create some additional tools like a WAF, for enhanced security</li></ol><p>Also, once we have this information we can easily use an LLM to create the actual deployment YAML:</p><ul><li>An example prompt is “<em>You are a DevOps expert. Generate a YAML deployment for a service with the image name &lt;&lt;name&gt;&gt;</em>”. Based on our scan (that can also be done with AI) we can conditionally add, for example:</li><li>“<em>Add an nginx service</em>”</li><li>“<em>Add a stateful DB service, running “+&lt;&lt;dbtype&gt;&gt;+” database</em>”</li></ul><p>And finally “<em>Only return the YAML text, without prefixes and suffixes</em>”</p><p>Now, all we need to do, if we want to make this process fully automatic is to throw in a script that will <strong>watch </strong>the relevant directory and take this YAML (when created or updated) and apply it to the relevant cluster. So the full cycle, GitOps style, is:</p><ol><li>Whenever a developer pushes her code, after passing the tests, and building the docker container for it, the deployment creation application is called</li><li>It scans the code and configuration and creates a YAML for deployment</li><li>This YAML is applied on the designated cluster, adding/removing resources to match the current deployment.</li></ol><p>That’s it! Zero manual deployment preparation. Always up to date. So.. what do you think, are we ready for the NoOps era?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a834a8505617" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Paperless, Fully Automated, State-Of-The-Art Tax System in 90 Days]]></title>
            <link>https://medium.com/@dan.erez/building-a-paperless-fully-automated-state-of-the-art-tax-system-in-90-days-49c1a1833ec2?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/49c1a1833ec2</guid>
            <category><![CDATA[tax-software]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[innovation]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Thu, 09 Mar 2023 11:36:43 GMT</pubDate>
            <atom:updated>2023-03-09T12:57:51.490Z</atom:updated>
            <content:encoded><![CDATA[<p>In many countries, the tax office (IRS in the US, for example) is central to the state’s tax collection on one hand, but as a government office, its technology and IT system are very old and inadequate on the other hand. This has many causes, which I won’t detail here, but it’s also common to other government offices. Such a situation affects not only the ability to collect the full tax from companies, businesses and individuals but also affects the ability of the government to manage its policy due to lack of current tax collection status and transparency. The citizens suffer twofold — directly and indirectly. Directly, because their interactions with the tax authorities are painful, due to old systems, lack of transparency, tedious processes etc. and indirectly, because the inability of the state to manage a modern tax system, with maximum collection and transparency, leaves less budget to invest in the citizens (e.g. build new roads, or even lower tax rates — why not?).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*nbrnAdKKnHLUN1l4PzfANQ.png" /><figcaption>We deserve a better tax system!</figcaption></figure><p>The irony is that now, in 2023, building a modern and capable tax system is fast and easy. I’m referring to the technological side, of course, but I believe it’s a crucial part of any tax system. An enabler that can pull everything else to a higher level. I will show the high level structure of such a system and even refer you to a demo I’ve built. Hopefully it can assist tax authorities worldwide to take another look and maybe even adopt that approach. Let’s start!</p><p>When talking about a modern tax authority, we can mean many things, and it’s country dependant, of course, but we can look at the OECD plans, for example: <a href="https://www.oecd.org/tax/forum-on-tax-administration/publications-and-products/tax-administration-3-0-the-digital-transformation-of-tax-administration.htm">https://www.oecd.org/tax/forum-on-tax-administration/publications-and-products/tax-administration-3-0-the-digital-transformation-of-tax-administration.htm</a></p><p>It’s a nice document, and it does use some up to date (true to 2019) buzz words as data driven, etc. but in order to build an actual system we need to select the relevant principles and dive deeper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*L6h-elLpOsV7LyIxadvEXg.png" /><figcaption>Modern systems are easy</figcaption></figure><p><strong>Principles</strong></p><p>As you can understand from this article’s title, paperless is one of the principle. It’s simple: NO. PAPER. EVER.</p><p>My favorite term from the OECD report is ‘tax just happening’. I think this summarizes everything — businesses and individuals don’t need to make a costly effort to report their business data to the tax authorities, we have APIs for that! This is actually the second term from the title: “Fully Automated”. This means NO. MANUAL. PROCESSES.</p><p>The last part of this article’s title is ‘State-of-the-art’. Yes, dear tax offices, it’s time to leap 50 years forward and land in the present. Modern software systems, scalable (yes, cloud!) API-based, with an excellent UX will make everyone’s life easier. No nightly batch processes, no unscalable mainframes, goodbye horrible screens that force me to manually enter details the system already knows again and again and again. Not to mention using AI and ML to predict, investigate, conclude, etc. OK, you get the drift: BUILD. MODERN. SYSTEMS.</p><p>Now that we’ve established the principles, let us detail some more features and concepts (only a partial list, of course) to get you in the mood:</p><p>- Reflect a near real time state (tax collection info, etc.) to the tax authority’s management</p><p>- A complete and updated personal area for every citizen and company (including an amazing mobile app)</p><p>- No need for filing a yearly income report! Using Open Banking we can get all the needed information</p><p>- Complete paperless work for citizens and employees</p><p>- Customer First approach for maximum ease for citizens and companies</p><p>- Smart management of the work at the Authority (work load balancing across the country, prioritization, etc.)</p><p>- Maximum use of government APIs (e.g. identification, sending messages, etc.) and upgrading connectivity to other entities in the state (government offices, banks, etc.)</p><p>- Using modern software development practices, including No Code/Low Code, BPM where possible to accelerate development</p><p>- Cloud first approach</p><p>The execution steps of such a system should be:</p><ul><li>Defining required APIs, and building a mock of the system for demonstration and feedback</li><li>Implementation of APIs, cand connecting to Legacy systems and Data Lakes</li><li>Creating the web applications for the tax authority’s employees and for the citizensm with gradual exposure</li><li>Release of mobile apps</li><li>Integration of structured work processes (BPM)</li><li>Connecting AI/ML modules</li><li>Migrating from old systems</li></ul><p><strong>Demo System</strong></p><p>The demo system for the new Tax Authority Management System (TAMS) can be seen in figure 1. Some parts (like the legacy systems) will be mocked and other parts (like the APIs) shall be implemented in full.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-cAoqrLQf0J5kvGy" /><figcaption>Figure 1: New Tax Authority Management System building blocks</figcaption></figure><p>To have a better grasp of this system, let’s look at three supported flows:</p><ol><li><strong>Transaction Reporting Flow (Figure 2)</strong></li></ol><p>This flow describes how a business reports a transaction (e.g. selling a product) to the tax authority via an API. The transaction information is validated and approved/rejected according to the relevant business rules. Later it is saved in the transaction DB and asynchronously sent to Legacy systems (Until fully migrated) and the Data Lake (for off line reporting and analysis). Since the VAT, income tax etc. is immediately deducted, this flow enables the Tax Authority to know the current tax collection status, in real time, <strong>and </strong>eliminates the need for the business owner to file a yearly report (combined with the next flow).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9jkfEORDLTt2HnwT" /><figcaption>Figure 2: Transaction Reporting Flow</figcaption></figure><p>2.<strong> Data Collection Flow (Figure 3)</strong></p><p>This flow describes how the tax authority can <strong>pull </strong>information from the business bank accounts (via Open Banking APIs) and update the other systems. This enables the business to avoid the yearly file reporting, should they choose to do so. Alternatively, a business should be able to file the yearly report via API and 3rd party systems (Or, if they like the pain, manually via the tax authority website).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NQFHfqbvn8lRXR4j" /><figcaption>Figure 3: Data Collection Flow</figcaption></figure><p>3. <strong>Donation Flow (Figure 4)</strong></p><p>This flow describes how an individual or a company can make a donation via the tax authority mobile app (or API) and receive an immediate tax refund to their account. Such a flow will encourage donations to needy organizations, while ensuring an immediate refund, thus also elevating the citizens’ trust in the tax authority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uthX0DMO89qiHlS5" /><figcaption>Figure 4: Donation Flow</figcaption></figure><p>Lastly, The main dashboard for decision makers shall look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ONTKEJ4b_2bs2k-y" /></figure><p>It will detail the current tax collection information, relevant business trends and alert any issues that need immediate attention. Every widget is clickable and can be drilled down to the root cause (e.g. the details of a closed business).</p><p>This demo can be a very good base for building a fully functioning, modern tax system. Now all that is needed is a true governmental desire to make things better… Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49c1a1833ec2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Browsers are the new servers!]]></title>
            <link>https://medium.com/@dan.erez/browsers-are-the-new-servers-e7ff87378e77?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7ff87378e77</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[innovation]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Thu, 27 Jan 2022 09:37:17 GMT</pubDate>
            <atom:updated>2022-01-27T09:37:17.496Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Intro</em></strong></p><p>Hybridization and distributed computing are a hot trend these days, and why not? They enable you to run your workloads anywhere — close to your customers, wherever servers are available and you are protected from failures in a data center — you are global!</p><p>But it’s not just that, it can also reduce the cost! Whether you choose between the cheapest cloud provider for a certain service or run your code on your in-house machine — you have a choice that can reduce costs.</p><p>Now we can take this a step further, at least as a mental exercise. Since a typical, medium size organization has hundreds of employees, maybe even thousands, it also means that this organization has hundreds or thousands machines. Hmm… that sounds great! But aren’t they already busy, buzzing with complicated calculations and energetic I/O operations all the time? Well, in one word: No. The average employee is at work for 8 hours, and actually straining his or her machine for far less than that. Meetings, lunch, browsing facebook, etc. not really burden a modern computer. We can leverage those thousands of servers to run stuff for free, as I already suggested <a href="https://medium.com/@dan.erez/you-are-your-own-cloud-7c1cf7256ce2">here</a>.</p><p>But let’s be even more adventurous! What if we could run those workloads <strong>without </strong>installing anything on the employee’s machine? Or in a different phrasing — what if I told you that every employee already has a secured container installed, ready for action?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/0*ySAmmE2_-DT-hizV" /></figure><p>Yes, it’s your browser!</p><p><em>Why a browser?</em></p><p>Well, if you see a browser just as a web page serving applications it does seem weird, but modern browsers are much, much more than that! Let’s take chrome, for example:</p><ul><li>It has a powerful V8 javascript engine</li><li>It can also run Web Assembly (nowadays, several languages — Go, Rust and more — can be compiled into Web Assembly so they can be executed in Chrome)</li><li>Each tab in a browser is an isolated environment, not only from other tabs, but also from the host machine, so it’s a safe environment!</li><li>It can run multiple workloads concurrently, either in different tabs or using service workers</li><li>It has a plethora of interesting and useful APIs, for example <a href="https://gpuweb.github.io/gpuweb/">WebGPU</a>, that enable you to use the GPU’s capabilities (e.g. for ML workloads) and many others</li><li>It has various storage options you can use safely for stateful workloads (local storage, session storage and even a small, SQL querable DB).</li><li>Easy communication to anywhere using HTTP, Web Sockets, WebRTC, etc.</li><li>Geolocation capabilities, to perform edge or near the customer computation</li></ul><p>I can go on and on, but I’ll just conclude with — Everybody has it! All desktops, all laptops and almost every mobile phones — billions of machines at your disposal.</p><p><em>How can it be done?</em></p><p>Wow, here you can really go wild and think about many bizarre options, but I’ll try to contain myself and describe a simple option.</p><p>OK, so obviously the task to execute or the code to run has to come from somewhere… and as with anything the browser executes, it will come from some web server. And we can think of two options:</p><ul><li>The browser can directly load the code to execute and run it (e.g. some calculation for an ML training). It will later be able to send the results to some API</li><li>The browser will load some general task management page and in turn it will load the code to execute. This will give more control over execution, handling the result, retrying, etc.</li></ul><p>So in any case we need a server with some backend code and a queue, for which we can submit jobs via API or some UI. This server will dispatch jobs to available browsers (via pull or push). The results can be send to some API, to save in a DB or continue the processing flow. it can look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/0*zLtqnN9TiHOU2wS9" /></figure><p><strong><em>Use case: Payslip generation</em></strong></p><p>Who doesn’t like pay slips? I know I do, so let’s generate some! Assume we are a company of 100000 employees and we’d like to generate payslip PDFs and mail them to the employees. Since this is a case where the same code (getting payslip info and generating the PDF) can run concurrently to reduce overall processing time, it is a good candidate for us. We shall use the employees’ browsers to also save on cloud resources.</p><p><em>Preparing the server</em></p><p>The server will be in charge of dispatching tasks to browsers. For simplicity, let’s assume this server is dedicated for this task, though in real life we’d like a general purpose server that will be able to accept all kinds of jobs and dispatch them to the workers.</p><p>Now, this server, at every 1st of every month, will:</p><ol><li>Query the active employees and their salary. For example, each employee’s data can look like this: {</li></ol><p>‘name’: ‘John Doe’,</p><p>‘address’: ’66 Main rd., SomeCity’</p><p>‘salary’:1000.50</p><p>}</p><p>2. Those employee data structure will be pushed to a queue for future handling. Once all employees data has been pushed to the queue, the scheduled task ends.</p><p>3. Whenever a client is connected and asks for a task, we send him two things:</p><p>a. Link to the js code that handles this task (Generating the PDF in this case)</p><p>b. The employee’s data</p><p>We can generelize this info in a general structure:</p><p>{</p><p>‘taskId’: ‘123e4567-e89b-12d3-a456–426614174000’</p><p>‘handler’: ‘/handlers/payslipsHandler.js’,</p><p>‘data’:{</p><p>name’: ‘John Doe’,</p><p>‘address’: ’66 Main rd., SomeCity’</p><p>‘salary’:1000.50</p><p>}</p><p>}</p><p>4. When the client finishes, we expect a response to indicate the result and the status. This can be done synchronously or (even better) asynchronously via a response queue. Such a queue can be common to all tasks — the server can read the responses, handle retries and pass results to the proper task’s response handler. A timeout mechanism should be in place in case the task never finishes (e.g. the user experienced a power loss).</p><p><em>Preparing the browser’s job</em></p><p>The browser will, once loaded the wrapper javascript code, will constantly:</p><ol><li>Ask for tasks to fulfill.</li><li>Run the task code</li><li>Send the result</li><li>Start over with no. 1</li></ol><p>In our example, the task code will take the employee’s salary details, and create the payslip pdf in the browser (with PDFKit, jsPDF etc.). This pdf will be sent as part of the response to the server (or sent to a response queue).</p><p>This is a simple task example, but one can easily imagine how it can evolve quickly in a real life scenario, for example:</p><ul><li>To enhance performance the details can be loaded from the client, using one or more APIs, so the server only sends the employee id and not the fill data object.</li><li>Do the necessary calculations for the pay slip, taxes and all, to save compute efforts on the server side.</li></ul><p><strong><em>Summary</em></strong></p><p>I hope you are now convinced that browsers are the new servers and you’re about to close your existing data center or cloud account…well, we are not there yet, but I hope I managed to show that browsers have some integral qualities that make them suitable to run distributed tasks.</p><p>Making this a common way to run tasks is a harder thing to accomplish. There are business models in which users get paid for their machine’s compute time, usually by downloading and running an application. This can be a cleaner, safer way to achieve that. Whoever manages to take advantage of this shall have an army of billions of browsers (in desktops, laptops and mobiles) at his command!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7ff87378e77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You are your own cloud]]></title>
            <link>https://medium.com/att-israel/you-are-your-own-cloud-7c1cf7256ce2?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c1cf7256ce2</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Fri, 25 Sep 2020 09:53:07 GMT</pubDate>
            <atom:updated>2023-11-14T08:49:32.310Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I made public clouds obsolete — A tale of a serverless advocate</em></p><p>In case you haven’t heard about FAAS (Functions as a Service) — it’s all about running your code on some servers you know (and care) nothing about. For example, AWS’ lambda functions let you upload code, not worry about deploying it to servers, and promise you (almost) infinite scalability and great performance at a cheap price. Sounds great!</p><p>I believe serverless functions are the future. It’s the purest form of code development — writing only the sweet code and caring about nothing else. It’s beautiful. It also forces you to develop in an API-centric approach and simplifies your system. In a mild usage pattern they are also cheaper than running code on a dedicated server. But they will still cost you money, and you can still do better — run serverless code and do it for free — Let me tell you how.</p><p>The average organization can easily spend millions of dollars per year for cloud services, as Forbes suggests here: <a href="https://www.forbes.com/sites/joemckendrick/2018/02/15/too-much-corporate-money-is-evaporating-into-the-cloud-survey-suggests/amp/">https://www.forbes.com/sites/joemckendrick/2018/02/15/too-much-corporate-money-is-evaporating-into-the-cloud-survey-suggests/amp/</a>.</p><p>Wow, that’s a lot of money! But why should you pay so much to Amazon or Google, when you have your own server farm (even if you don’t know it yet)? A mid-size organization owns <strong>hundreds </strong>of work stations, often even <strong>thousands</strong>. A typical employee utilizes an average of 15% of his or her CPU, and about 30% of the memory and only for the average duration of 8 hours a day, leaving it idle for about 16 hours, begging for action. Oh, not to mention that workstations are getting stronger all the time — in Israel, for example, the minimum spec you can find in a computer store nowadays is an 8 GB i5 machine with 4 cores. That’s plenty for running Microsoft Word and an occasional Solitaire game…</p><p>If your company’s offices or employees reside in several geographical locations it gets even better — you can find dozens of idle machines in any hour of the day! So why not utilize them to run ‘serverless’ functions? You already paid for them and they just sit there…Serverless functions are short lived, stateless, run inside an isolated docker container which makes them perfect for such a dynamic environment.</p><p>This idea isn’t new — actually, AWS uses it to run their own lambda functions (From AWS docs: “Every time an event notification is received for your function, AWS Lambda quickly locates free capacity within its compute fleet and runs your code”) …so why can’t you? Well, as a matter of fact, yes you can!</p><p>All you have to do is use the right tools that will give you, besides the ability to run functions of course, some security, some resource usage control and the needed orchestration for all those servers. Nowadays there are several on premise open source FAAS (function as a service) frameworks out there. Let’s take a look, for example, at Oracle’s Open Source FN project (http://fnproject.io). Here is its architecture (from the FN project web site):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*LN34GpOnrshaa2PZ" /></figure><p>Those blue puppies can run on your Windows machine and do their thing. Since they run the function inside a docker container, they are isolated from the host machine and cannot compromise any data on it, so security is covered (as far as docker’s own security mechanism is considered safe).</p><p>The FN load balancer (LB) takes care of routing the requests and since it is open source, you can make it as smart as you like, add discovery capabilities, etc.. So orchestration is pretty much covered too.</p><p>Resource usage control is a bit trickier, since the servers should constantly notify their status and resource availability to the LB so it can do the routing wisely. But don’t despair — it’s not very hard to add, and in any case, companies like <a href="http://naga.uno/">Naga </a>give you all that, and can even do an ML based capacity planning to optimize the allocation of function and ensure maximum scalability.</p><p>In addition, this concept can also benefit organizations that cannot or won’t put sensitive data in public clouds (like banks or governments or any company with sensitive data). Why shouldn’t they also enjoy infinite scalability for their workloads? The end result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*cLTMeCb-U2ZrMHQH" /><figcaption>Running it in house</figcaption></figure><p>Goodbye huge cloud bills and precious data scattered all over the world, hello in-house resource maximization… Let’s aim for the clouds!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c1cf7256ce2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/att-israel/you-are-your-own-cloud-7c1cf7256ce2">You are your own cloud</a> was originally published in <a href="https://medium.com/att-israel">AT&amp;T Israel Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Nexus OSS repository in an isolated environment]]></title>
            <link>https://medium.com/att-israel/using-nexus-oss-repository-in-an-isolated-environment-1ac9d1265184?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ac9d1265184</guid>
            <category><![CDATA[datapower]]></category>
            <category><![CDATA[nexus]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Wed, 18 Mar 2020 11:00:31 GMT</pubDate>
            <atom:updated>2020-03-18T11:00:31.650Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>No internet access, no libraries?</strong></p><p>In our workplace, like in many other big firms, government offices, and banks, the internal network is isolated from the outside world. Nothing goes out and nothing goes in. But, how can you conveniently work with open source libraries if you cannot use maven or npm (and other repositories) to fetch needed libraries?</p><p>Nexus (<a href="https://www.sonatype.com/product-nexus-repository">https://www.sonatype.com/product-nexus-repository</a>), and other similar products can be installed in pairs, to bridge between networks. But AFAIK that topology can only work in synchronous mode and you cannot add your own asynchronous checks like using sandboxes or anti virus checks — and that can be a problem. Plus, we wanted to use only the free, open source version of nexus (OSS), as we try to rely on open source as much as possible.</p><p>So we came up with a solution for that, drawn here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ScQlvT0QPkd6iloc" /></figure><p>Basically, we act as a proxy to the internal Nexus, receiving its requests (initiated by developers issuing ‘mvn install’ or ‘npm install’ commands). Next, we pass the requests to the external network via IBM’s Data Power (which verifies the request, in case someone tries to exploit the end point — similar products exist as well). Data Power passes the request to an external proxy, with internet access. This external proxy downloads the required library, along with all its dependencies, and passes it on to the organizational file checking system (sandboxes, antivirus, etc.). If the file is approved it is copied into the internal network (via a vault or a similar mechanism). There, the internal proxy comes into live again, picks up those libraries and uploads them into Nexus. Then the developer can retry to fetch the libraries and… voilà! The libraries are there and he can use them in his code.</p><p><strong>Inner Proxy</strong></p><p>The inner proxy is a Java Spring Boot application. It has two parts:</p><ul><li>The first part is a REST controller, exposing a GET url that accepts requests from Nexus. Using a servlet filter these requests are caught and sent to the DataPower (Listing 1).</li><li>The second part watches a designated folder, to which the approved libraries are copied (wrapped in a zip file). It extracts the libraries from the zip and uploads them into Nexus (Listing 2).</li></ul><p><strong>Outer Proxy</strong></p><p>The outer proxy is also a Java Spring Boot application. It accepts GET requests for the needed libraries. Then it downloads the libraries and their dependencies from maven or npm, and places them in a designated folder. The organizational file checking system will take the files from there ,check them, and if they are approved they will be moved into the inner network wrapped as a zip file (Listing 3).</p><p>That’s it! You are welcome to use a similar solution in your environment and start enjoying the wealth of open source libraries out there…</p><p><strong>Listing 1 — Intercepting the requests</strong></p><p>public class NexusInterceptingFilter extends DispatcherServlet {</p><p>private static final long serialVersionUID = 1L;</p><p>private static final String DP_URL_KEY = “dp_url”;</p><p>private static final String SEPARATOR = “/”;</p><p>protected static Logger logger = LoggerFactory.getLogger(NexusInterceptingFilter.class);</p><p>@Override</p><p>protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {</p><p>if (!(request instanceof ContentCachingRequestWrapper)) {</p><p>request = new ContentCachingRequestWrapper(request);</p><p>}</p><p>if (!(response instanceof ContentCachingResponseWrapper)) {</p><p>response = new ContentCachingResponseWrapper(response);</p><p>}</p><p>HandlerExecutionChain handler = getHandler(request);</p><p>try {</p><p>super.doDispatch(request, response);</p><p>} finally {</p><p>handleRequests(request, response, handler);</p><p>updateResponse(response);</p><p>}</p><p>}</p><p>private void handleRequests(HttpServletRequest requestToCache, HttpServletResponse responseToCache,</p><p>HandlerExecutionChain handler) {</p><p>logger.info(“&gt;&gt;&gt;&gt;&gt; Fetching: “+ requestToCache.getRequestURI());</p><p>// This is for java only</p><p>if (requestToCache.getRequestURI().endsWith(“.pom”)) {</p><p>// make the request for the lib ( etc. abbot/abbot/0.13.0/abbot-0.13.0.pom )</p><p>RestTemplate rest = new RestTemplate();</p><p>Environment env = (Environment)ApplicationContextProvider.getBeanByClass(Environment.class);</p><p>String dpUrl = env.getProperty(DP_URL_KEY);</p><p>String theUrl = dpUrl+”?libName=”+getLibRequest(requestToCache.getRequestURI());</p><p>logger.info(“The request: “+theUrl);</p><p>rest.getForObject(theUrl, Void.class);</p><p>}</p><p>}</p><p>private String getLibRequest(String requestURI) {</p><p>if (requestURI.endsWith(“.pom”)) {</p><p>String[] parts = requestURI.split(SEPARATOR);</p><p>String version = parts[parts.length — 2];</p><p>String artifactId = parts[parts.length — 3];</p><p>StringBuilder grp = new StringBuilder();</p><p>for(int i=2;i&lt;parts.length — 3;i++) {</p><p>grp.append(parts[i]).append(“.”);</p><p>}</p><p>return grp.toString().substring(0,grp.length()-1)+SEPARATOR+</p><p>artifactId+SEPARATOR+version;</p><p>}</p><p>return null;</p><p>}</p><p>private void updateResponse(HttpServletResponse response) throws IOException {</p><p>ContentCachingResponseWrapper responseWrapper = WebUtils.getNativeResponse(response,</p><p>ContentCachingResponseWrapper.class);</p><p>responseWrapper.copyBodyToResponse();</p><p>}</p><p>}</p><p><strong>Listing 2 — Upload to Nexus</strong></p><p>@Component</p><p>public class ScheduledLibrariesReader {</p><p>private static final String MANIFEST = “manifest.txt”;</p><p>@Value(“${vaultFolder}”)</p><p>private String vaultFolder;</p><p>@Value(“${tempFolde}”)</p><p>private String tempFolder;</p><p>@Value(“${nexus_url}”)</p><p>private String nexusUploadUrl;</p><p>protected static Logger logger = LoggerFactory.getLogger(ScheduledLibrariesReader.class);</p><p>@Scheduled(fixedRate = 60000)</p><p>public void readFiles() throws Exception {</p><p>// Read all files (= zip for java)</p><p>try (Stream&lt;Path&gt; paths = Files.walk(Paths.get(vaultFolder))) {</p><p>paths.filter(Files::isRegularFile).forEach(f -&gt; {</p><p>try {</p><p>// open the zip to a temp folder we create</p><p>String theFolder = parseAndRename(f);</p><p>// upload all files from this dir, according to the manifest</p><p>upload(theFolder);</p><p>// remove zip and files</p><p>removeAll(theFolder, f);</p><p>} catch (Exception e) {</p><p>throw new RuntimeException(e);</p><p>}</p><p>});</p><p>}</p><p>}</p><p>private String parseAndRename(Path zipFile) throws Exception {</p><p>// output dir is under the temp folder in a new folder, based on the zip name</p><p>String dirName = tempFolder + “/”</p><p>+ zipFile.getFileName().toString().substring(0, zipFile.getFileName().toString().lastIndexOf(“.”));</p><p>File destDir = new File(dirName);</p><p>if (!destDir.exists()) {</p><p>destDir.mkdir();</p><p>}</p><p>byte[] buffer = new byte[1024];</p><p>ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile.toFile()));</p><p>ZipEntry zipEntry = zis.getNextEntry();</p><p>while (zipEntry != null) {</p><p>File newFile = new File(destDir, zipEntry);</p><p>FileOutputStream fos = new FileOutputStream(newFile);</p><p>int len;</p><p>while ((len = zis.read(buffer)) &gt; 0) {</p><p>fos.write(buffer, 0, len);</p><p>}</p><p>fos.close();</p><p>zipEntry = zis.getNextEntry();</p><p>}</p><p>zis.closeEntry();</p><p>zis.close();</p><p>//</p><p>return dirName;</p><p>}</p><p>@SuppressWarnings(“unchecked”)</p><p>private void upload(String theFolder) throws Exception {</p><p>List&lt;String&gt; lines = Files.readAllLines(new File(theFolder+”/”+MANIFEST).toPath());</p><p>for (String line : lines) {</p><p>String[] parts = line.split(“:”); // group/artifact/version//filename</p><p>ByteArrayOutputStream stdout = new ByteArrayOutputStream();</p><p>ByteArrayOutputStream stderr = new ByteArrayOutputStream();</p><p>Map map = new HashMap();</p><p>map.put(“file”, new File(theFolder + “/” + parts[3]));</p><p>CommandLine cmdLine = new CommandLine(MAVEN_LOC+”mvn.cmd”);</p><p>cmdLine.addArgument(“deploy:deploy-file”);</p><p>cmdLine.addArgument(“-DgroupId=” + parts[0]);</p><p>cmdLine.addArgument(“-DartifactId=” + parts[1]);</p><p>cmdLine.addArgument(“-Dversion=” + parts[2]);</p><p>cmdLine.addArgument(“-DgeneratePom=true”);</p><p>cmdLine.addArgument(“-Dpackaging=jar”);</p><p>cmdLine.addArgument(“-DrepositoryId=nexus”);</p><p>cmdLine.addArgument(“-Durl=”+nexusUploadUrl);</p><p>cmdLine.addArgument(“-Dfile=${file}”);</p><p>cmdLine.setSubstitutionMap(map);</p><p>DefaultExecutor executor = new DefaultExecutor();</p><p>PumpStreamHandler streamHandler = new PumpStreamHandler(stdout, stderr);</p><p>executor.setStreamHandler(streamHandler);</p><p>DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();</p><p>executor.execute(cmdLine, resultHandler);</p><p>resultHandler.waitFor();</p><p>logger.info(“Exit code for uploading “+line+” is “+resultHandler.getExitValue());</p><p>logger.info(“Error is:\n”+stderr.toString());</p><p>logger.info(“Output is:\n”+stdout.toString());</p><p>}</p><p>}</p><p><strong>Listing 3 — Downloading from Maven</strong></p><p>@RestController</p><p>public class ProxyController {</p><p>private static final String MANIFEST = “manifest.txt”;</p><p>private static final String SEPARATOR = “\\”;</p><p>@Value(“${vaultFolder:d:/Temp/repo}”)</p><p>private String vaultFolder;</p><p>protected static Logger logger = LoggerFactory.getLogger(ProxyController.class);</p><p>@GetMapping(“/fetch”)</p><p>// Expecting groupId/artifactId/version</p><p>public void fetchLib(@RequestParam String libName) throws Exception {</p><p>// Currently supporting Maven and NPM</p><p>if (isMavenLib(libName)) {</p><p>List&lt;Path&gt; libs = fetchMavenLibs(libName);</p><p>moveToVault(libs);</p><p>} else {</p><p>// assume npm</p><p>fetchJsonLib(libName);</p><p>}</p><p>}</p><p>private void moveToVault(List&lt;Path&gt; libs) throws IOException {</p><p>StringBuilder manifest = new StringBuilder();</p><p>String zipFile = vaultFolder + “/nexus_” + System.currentTimeMillis() + “.zip”;</p><p>byte[] buffer = new byte[1024];</p><p>ZipOutputStream zos = null;</p><p>FileInputStream fis = null;</p><p>try {</p><p>FileOutputStream fos = new FileOutputStream(zipFile);</p><p>zos = new ZipOutputStream(fos);</p><p>//</p><p>for (Path path : libs) {</p><p>manifest.append(getPartsString(path)).append(“\n”);</p><p>// add to zip</p><p>fis = new FileInputStream(path.toFile());</p><p>// begin writing a new ZIP entry, positions the stream to the start of the entry data</p><p>zos.putNextEntry(new ZipEntry(path.getFileName().toString()));</p><p>int length;</p><p>while ((length = fis.read(buffer)) &gt; 0) {</p><p>zos.write(buffer, 0, length);</p><p>}</p><p>zos.closeEntry();</p><p>// close the InputStream</p><p>fis.close();</p><p>//Files.move(p, new File(vaultFolder + “/” + p.getFileName()).toPath());</p><p>}</p><p>// add the manifest to the zip</p><p>zos.putNextEntry(new ZipEntry(MANIFEST));</p><p>zos.write(manifest.toString().getBytes());</p><p>zos.closeEntry();</p><p>//</p><p>} finally {</p><p>zos.close();</p><p>}</p><p>}</p><p>private List&lt;Path&gt; fetchMavenLibs(String libName) {</p><p>logger.info(“Fetching lib “ + libName);</p><p>String groupId = getGroupId(libName);</p><p>String artifactId = getArtifactId(libName);</p><p>String version = getVersion(libName);</p><p>JkDependencySet deps = JkDependencySet.of().and(groupId + “:” + artifactId + “:” + version)</p><p>// e.g. “com.threerings:tripleplay:1.4”)</p><p>.withDefaultScopes(COMPILE_AND_RUNTIME);</p><p>JkDependencyResolver resolver = JkDependencyResolver.of(JkRepo.ofMavenCentral());</p><p>List&lt;Path&gt; libs = resolver.resolve(deps, RUNTIME).getFiles().getEntries();</p><p>logger.info(“Downloaded lobs: {}”, libs);</p><p>return libs;</p><p>}</p><p>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ac9d1265184" width="1" height="1" alt=""><hr><p><a href="https://medium.com/att-israel/using-nexus-oss-repository-in-an-isolated-environment-1ac9d1265184">Using Nexus OSS repository in an isolated environment</a> was originally published in <a href="https://medium.com/att-israel">AT&amp;T Israel Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recording Web Requests and Responses in Spring Boot, Using Zuul Gateway]]></title>
            <link>https://medium.com/att-israel/recording-web-requests-and-responses-in-spring-boot-using-zuul-gateway-fc888362f5e6?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc888362f5e6</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-cloud]]></category>
            <category><![CDATA[gateway]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Sun, 22 Sep 2019 12:47:59 GMT</pubDate>
            <atom:updated>2019-09-22T12:47:59.557Z</atom:updated>
            <content:encoded><![CDATA[<p>An easy way to capture the incoming requests to your server and replay them can be very useful. For example, if you lack an automation team, or simply want to be quick about it, you can record the REST requests of a scenario and play them again after every push to GIT. You can also use the recorded requests to simulate many users. Or, you can analyze the requests to learn useful statistics, etc. You get the idea.</p><p>OK, so how can we do it the easy way? First, we’ll exploit spring boot Zuul gateway filters feature — this gateway can activate custom filters for every request and every response. An handler must simply extend ZuulFilter and provide information of:</p><p>1. The Filter’s type, for example ‘pre’ means a pre-routing filter. Other values can be ‘post’for post-routing filters or ‘route’ for routing to an origin.</p><p>2. The Filter’s order in the chain of filters. A lower number will cause the filter to be executed before a filter with a higher number.</p><p>3. Should filter — if the filter should be applied for a given route.</p><p>4. Run — the actual things you want to do.</p><p>We’ll use these filters to record the incoming requests (listing 1) and outgoing responses (listing 2) requests to a file. Naturally, you can record them to DB, to S3, or to whatever repository you’ll be comfortable to use later. No you can analyze this information at your own leisure. The ‘global Id’ is a GUID saved on ThreadLocal and helps us to bind together matching requests and responses.</p><p><em>Listing 1 — Recording incoming requests</em></p><p>@Component</p><p>@Profile(“recording”)</p><p><strong>public</strong> <strong>class</strong> LogRequestFilter <strong>extends</strong> ZuulFilter {</p><p><strong>private</strong> <strong>static</strong> Logger <em>log</em> = LoggerFactory.<em>getLogger</em>(LogRequestFilter.<strong>class</strong>);</p><p>@Value(“${recording.file:c:/temp/record.txt}”)</p><p><strong>private</strong> String recordFile;</p><p>@Override</p><p><strong>public</strong> String filterType() {</p><p><strong>return</strong> “pre”;</p><p>}</p><p>@Override</p><p><strong>public</strong> <strong>int</strong> filterOrder() {</p><p><strong>return</strong> 2;</p><p>}</p><p>@Override</p><p><strong>public</strong> <strong>boolean</strong> shouldFilter() {</p><p><strong>return</strong> true;</p><p>}</p><p>@Override</p><p><strong>public</strong> Object run() {</p><p>RequestContext ctx = RequestContext.<em>getCurrentContext</em>();</p><p>HttpServletRequest request = <strong>new</strong> HttpServletRequestWrapper(ctx.getRequest());</p><p>String requestData = <strong>null</strong>;</p><p><strong>try</strong> {</p><p><strong>if</strong> (request.getContentLength() &gt; 0 ) {</p><p>requestData = CharStreams.<em>toString</em>(request.getReader());</p><p>}</p><p>} <strong>catch</strong> (Exception e) {</p><p><em>log</em>.error(“Error parsing request”, e);</p><p><strong>throw e</strong>;</p><p>}</p><p><strong>try</strong> {</p><p>String line = String.<em>format</em>(“Request, %s, %s,%s,%s \r\n”,</p><p><em>getContext</em>().getGlobalId(), request.getRequestURL(),</p><p>request.getMethod(),requestData);</p><p>BufferedWriter bw = Files.<em>newBufferedWriter</em>(Paths.<em>get</em>(recordFile),</p><p>Charset.<em>forName</em>(“UTF-8”), StandardOpenOption.<strong><em>APPEND</em></strong>);</p><p>bw.write(line);</p><p>bw.close();</p><p>}<strong>catch</strong> (IOException e) {</p><p><em>log</em>.error(“Error writing request”, e);</p><p><strong>throw e</strong>;</p><p>}</p><p><strong>return</strong> <strong>null</strong>;</p><p>}</p><p>}</p><p><em>Listing 2 — Recording outgoing responses</em></p><p>@Component</p><p>@Profile(“recording”)</p><p><strong>public</strong> <strong>class</strong> LogResponseFilter <strong>extends</strong> ZuulFilter {</p><p><strong>private</strong> <strong>static</strong> Logger <em>logger</em> = LoggerFactory.<em>getLogger</em>(LogResponseFilter.<strong>class</strong>);</p><p>@Value(“${recording.file:c:/temp/record.txt}”)</p><p><strong>private</strong> String recordFile;</p><p>@Override</p><p><strong>public</strong> String filterType() {</p><p><strong>return</strong> “post”;</p><p>}</p><p>@Override</p><p><strong>public</strong> <strong>int</strong> filterOrder() {</p><p><strong>return</strong> 2;</p><p>}</p><p>@Override</p><p><strong>public</strong> <strong>boolean</strong> shouldFilter() {</p><p><strong>return</strong> true;</p><p>}</p><p>@Override</p><p><strong>public</strong> Object run() {</p><p>RequestContext ctx = RequestContext.<em>getCurrentContext</em>();</p><p><strong>try</strong> (<strong>final</strong> InputStream responseDataStream = ctx.getResponseDataStream())</p><p>{</p><p><strong>final</strong> String responseData =</p><p>CharStreams.<em>toString</em>(<strong>new</strong> InputStreamReader(responseDataStream,</p><p>“UTF-8”));</p><p><strong>try</strong> {</p><p>String line = String.<em>format</em>(“Response, %s, %s \r\n”,</p><p><em>getContext</em>().getGlobalId(), responseData);</p><p>BufferedWriter bw = Files.<em>newBufferedWriter</em>(Paths.<em>get</em>(recordFile),</p><p>Charset.<em>forName</em>(“UTF-8”), StandardOpenOption.<strong><em>APPEND</em></strong>);</p><p>bw.write(line);</p><p>bw.close();</p><p>}<strong>catch</strong> (IOException e) {</p><p><em>logger</em>.error(“Error writing response”, e);</p><p><strong>throw e</strong>;</p><p>}</p><p>ctx.setResponseBody(responseData);</p><p>} <strong>catch</strong> (IOException e) {</p><p><em>logger</em>.error(“Error reading body”,e);</p><p><strong>throw e</strong>;</p><p>}</p><p><strong>return</strong> <strong>null</strong>;</p><p>}</p><p>}</p><p>Note that both beans are active only when a ‘recording’ profile is declared in application.properties.</p><p>A common use case would be to use this data for ‘automation’, meaning running the recorded scenarios whenever needed (after a code push, nightly, etc.). Request values can be replaced by parameters, that will be populated from excel (for example) and enable running the same test with different values.</p><p>Replaying can be done in a straightforward way, using Spring’s RestTemplate. The recording file is the input to the player, which simply sends the requests lines as REST requests, using the recorded data as request body for POST requests, where needed.</p><p>We can also add a validator that compares the responses to the response lines in the recording. Since some values in the response will be different for sure (such as timestamp fields, or id fields for created objects) we can make the validator smarter and do validations like ‘id must not be null’ instead of a naïve string comparison.</p><p>Sending multiple requests in parallel to check load balancing (or simply see the behavior of your app with more than one request at a time) is fairly simple as well, using Java’s Executor to run the same recording multiple times in parallel.</p><p>These were just a few example of usages for such recordings. If you find some other useful usages, please let me know!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc888362f5e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/att-israel/recording-web-requests-and-responses-in-spring-boot-using-zuul-gateway-fc888362f5e6">Recording Web Requests and Responses in Spring Boot, Using Zuul Gateway</a> was originally published in <a href="https://medium.com/att-israel">AT&amp;T Israel Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I exposed an entire PL/SQL based application as REST APIs in less than a week and saved tons…]]></title>
            <link>https://medium.com/att-israel/how-i-exposed-an-entire-pl-sql-based-application-as-rest-apis-in-less-than-a-week-and-saved-tons-ca97ced246ac?source=rss-ea05b98dc820------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca97ced246ac</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[plsql]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Dan Erez]]></dc:creator>
            <pubDate>Sun, 24 Feb 2019 08:30:08 GMT</pubDate>
            <atom:updated>2019-02-24T08:30:08.318Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How I exposed an entire PL/SQL based application as REST APIs in less than a week and saved tons of money for my company</strong></h3><p>Back in the good(?) old days PL/SQL applications than ran inside an Oracle DB were quite the thing. All the logic was written in the DB, close to the data. And everything ran fast. Stuff like maintainability, lighter open source databases, modern APIs, micro services etc. only emerged later.</p><p>I used to work for a company with such an application and the company encountered a problem — an old PL/SQL based application was in an un-maintainable state (people who even knew PL/SQL became scares), the application could not be offered to new customers due to its old technology and even existing clients demanded modern REST APIs to integrate with the system. An estimation of manually exposing REST APIs for each PL/SQL procedure (we had almost 10000 of those) was a year of work for three developers — three man years! But during this time the application will still be un-sellable, and existing customers might not be patient enough and dump us for shinier application — the situation looked dire… Then I came and said — I can expose all PL/SQL procedures in less than a week! And I did J. This is how:</p><p>The secret was to automate the entire process, and this was doable thanks to the fact that java enables us to:</p><p>a. Investigate PL/SQL procedures that live in a DB (names, parameters, return value types etc.)</p><p>b. Call PL/SQL procedures and process the returned data</p><p>c. Easily generate java classes</p><p>Investigating PL/SQL procedure was done using JDBC. To get all procedures I needed to connect to the DB, get the metadata and select the desired procedures:</p><p>Get the connection:</p><p>conn = DriverManager.getConnection(“jdbc:oracle:thin:@” + dbUrl + “:” + dbName(),</p><p>username, password);</p><p>Get DB metadata (see java API for details):</p><p>DatabaseMetaData meta = conn.getMetaData();</p><p>Query for procedures (in this case we extract data for a specific catalog and schema, but getting all procedures):</p><p>ResultSet resultSet = meta.getProcedureColumns(catalogName,schemaPattern, “%”,“%”);</p><p>Iterate the data and save it for later use. The code here is simplified, so we just assign the info to variables. In practice we accumulate procedure data and identified the input and output parameters information.</p><p>while (resultSet.next()) {</p><p>procadureCatalog = resultSet.getString(“PROCEDURE_CAT”);</p><p>procadureName = resultSet.getString(“PROCEDURE_NAME”);</p><p>remarks = resultSet.getString(“REMARKS”));</p><p>position = resultSet.getInt(“ORDINAL_POSITION”);</p><p>// input or output param (or both)</p><p>colType = resultSet.getInt(“COLUMN_TYPE”);</p><p>colName = resultSet.getString(“COLUMN_NAME”));</p><p>dataType = resultSet.getInt(“DATA_TYPE”);</p><p>dataTypeName = resultSet.getString(“TYPE_NAME”);</p><p>length = resultSet.getInt(“LENGTH”));</p><p>}</p><p>This returned some useful details on each procedure — its name (which was meaningful, hopefully), its parameters and their type, its return values and even all the comments it has, if available. This valuable info will be used when we call the procedure. A useful class we used is @NamedStoredProcedureQuery (which in turn uses @StoredProcedureParameter). These classes allow us to describe a stored procedure in java in order to call it through JPA. We generate them using the information we extracted before from the DB metadata and the outcome looks like this:</p><p>@NamedStoredProcedureQuery(</p><p>name = “calculate”,</p><p>procedureName = “calculate”,</p><p>parameters = {</p><p>@StoredProcedureParameter(mode = ParameterMode.IN, type = Double.class, name = “itemPrice”),</p><p>@StoredProcedureParameter(mode = ParameterMode.IN, type = Double.class, name = “itemQuantity”),</p><p>@StoredProcedureParameter(mode = ParameterMode.OUT, type = Double.class, name = “total”)</p><p>}</p><p>)</p><p>Once we generated that, calling the procedure is a breeze using JPA’s :</p><p>StoredProcedureQuery query =</p><p>this.em.createNamedStoredProcedureQuery(“calculate”);</p><p>query.setParameter(“itemPrice “, 1.23d);</p><p>query.setParameter(“itemQuantity “, 9.5);</p><p>query.execute();</p><p>Double total = (Double) query.getOutputParameterValue(“total”);</p><p>OK, so we now we know how to generate calls to stored procedure! Exposing this as REST is easy. Since we can generate a REST controller that will invoke the call. It is up to you to decide if you want to invoke the call directly from the controller or use an N-Tier architecture and add service and DAO layers in between, but the principal is the same. For example, we can generate:</p><p>@RequestMapping(“/math”)</p><p>@RestController</p><p>@CrossOrigin</p><p>public class MathController {</p><p>@GetMapping(“/calculate”)</p><p>public Double calculate(@PathParam Double itemPrice,</p><p>@PathParam Double itemQuantity) {</p><p>return … (call the calculation described above)</p><p>}</p><p>}</p><p>We can also generate unit tests easily as well, and read the input parameters values from exce, to enabe easy testing, making sure nothing got lost in the translation.</p><p>The code generation itself can be done ‘manually’, by appending strings, but this is obviously less comfortable. A better approach is to use templates and some replacement library like Velocity. Even java’s MessageFormat can be handy here:</p><p>Object[] params = new Object[]{“hello”, “!”};</p><p>String msg = MessageFormat.format(“{0} world {1}”, params);</p><p>And, if you want to live on the edge, you can always use a library like <a href="https://asm.ow2.io/">ASM</a> or <a href="https://commons.apache.org/proper/commons-bcel/">BCEL</a> to generate classes or <a href="https://javaee.github.io/jaxb-codemodel/">CodeModel</a> to generate java source files, thus making sure the syntax is correct and the generated classes can be easily modified (adding annotations, for example) in a way that will not break compilation.</p><p>This way a few man years have turned into a week and the customers were happy, sales persons could sell the renovated application and we had time to think about the next innovation…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca97ced246ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/att-israel/how-i-exposed-an-entire-pl-sql-based-application-as-rest-apis-in-less-than-a-week-and-saved-tons-ca97ced246ac">How I exposed an entire PL/SQL based application as REST APIs in less than a week and saved tons…</a> was originally published in <a href="https://medium.com/att-israel">AT&amp;T Israel Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>