January 05, 2022

Top 20 Apache Struts 2 Interview Questions and Answers

  

Struts 2 is a Java enterprise application framework for constructing web applications. It was created by the Apache Software Foundation. In the year 2006, it was first released. It's written in the Java programming language. It is cross-platform compatible. It is built on the MVC architecture, which is a software design paradigm for creating applications. Struts 2 includes features such as simplified testability, Ajax support, Thread-safety, and Template support, among others.

Apache Cassandra Interview Questions and Answers

Ques. 1): What exactly is Struts2?

Answer:

Apache Struts2 is a Java web application framework that is free source. The OpenSymphony WebWork framework is the foundation for Struts2. It's a significant improvement over Struts1, making it more adaptable, simple to use, and extendable. Action, Interceptors, and Result pages are the three main components of Struts2.

Struts2 offers a variety of options for creating Action classes and configuring them using struts.xml or annotations. For common jobs, we can make our own interceptors. Struts2 includes a large number of tags and makes use of the OGNL expression language. To render result pages, we can design our own type converters. JSPs and FreeMarker templates can be used as result pages.

 Apache Camel Interview Questions and Answers

Ques. 2): What are some of Struts2's features?

Answer:

Here are some of the fantastic features that can persuade you to use Struts2.

POJO forms and POJO actions − Struts2 has done away with the Action Forms that were an integral part of the Struts framework. With Struts2, you can use any POJO to receive the form input. Similarly, you can now see any POJO as an Action class.

Tag support − Struts2 has improved the form tags and the new tags allow the developers to write less code.

AJAX support − Struts2 has recognised the take over by Web2.0 technologies, and has integrated AJAX support into the product by creating AJAX tags, that function very similar to the standard Struts2 tags.

Easy Integration − Integration with other frameworks like Spring, Tiles and SiteMesh is now easier with a variety of integration available with Struts2.

Template Support − Support for generating views using templates.

Plugin Support − The core Struts2 behaviour can be enhanced and augmented by the use of plugins. A number of plugins are available for Struts2.

Apache Ant Interview Questions and Answers

Ques. 3): What's the difference between Struts 1 and Struts 2?

Answer: 

This is a list of the most common Strut 2 interview questions. The action class in Strut 1 is not a POJO, hence it must inherit the abstract class. An action servlet is used as the front controller. Only JSP is used for the component view. A configuration file can be inserted in the WEB-INF directory in section 1. When processing requests, it makes use of the Request Processor class. Actions and models are separated in Strut 1.

The action class in Strut 2 is a POJO, therefore there's no need to inherit any classes or implement any interfaces. For the view component, it has JSP, free-market, and so on. The function controller in strut 2 is the Struts Prepare and Execute filter. In this, a configuration file must be named as struts.xml and placed inside the classes directory. It uses the concept of Interceptors while processing the request. In strut 2, action and models are combined within the action class.

Apache Tomcat Interview Questions and Answers

Ques. 4): In Struct2, What Is The Use Of Struts.properties?

Answer:

This configuration file allows you to override the framework's default behaviour. In fact, all of the properties in the struts.properties configuration file can be defined in the web.xml using the init-param, as well as in the struts.xml configuration file using the constant tag. However, if you prefer to keep things separate and more struts specific, you can create this file in the WEB-INF/classes folder. The default values configured in default.properties, which is included in the struts2-core-x.y.z.jar distribution, will be overridden by the values configured in this file.

Apache Kafka Interview Questions and Answers

Ques. 5): Explain The Life Cycle Of A Request In Struct2 Application?

Answer :

Following is the life cycle of a request in Struct2 application −

  • User sends a request to the server for requesting for some resource (i.e pages).
  • The FilterDispatcher looks at the request and then determines the appropriate Action.
  • Configured interceptors functionalities applies such as validation, file upload etc.
  • Selected action is executed to perform the requested operation.
  • Again, configured interceptors are applied to do any post-processing if required.
  • Finally the result is prepared by the view and returns the result to the user.

Apache Tapestry Interview Questions and Answers

Ques. 6): What are the inbuilt themes that are provided by strut 2?

Answer:

There are 3 different inbuilt themes:

Simple theme: It is a minimal theme which is having very little content. It means that the text field tag renders the HTML tag without label, validation, error reporting or any other formatting or functionality.

XHTML theme: It is referred to as the default theme used by struts 2 and provides all the basics that a simple theme provides. It adds the other several features like standard two-column table layout for the HTML labels for each of the HTML, validation and error reporting etc.

Css_xhtml theme: This is the theme that provides all the basics that the simple theme provides, and it adds other several features like the standard two-column CSS-based layout and using div tag for HTML struts tags, labels for each of the HTML struts tags and placed according to the CSS style sheet.

Apache Ambari interview Questions & Answers

 Ques. 7): What is internationalization and how does it work?

Answer:

This is one of the most common Struts 2 Interview Questions that is asked during an interview. Localization refers to the process of planning and implementing products and services so that they may be easily modified to specific local languages and cultures, whereas internationalization refers to the act of enabling localization.

Apache Hive Interview Questions & Answers

Ques. 8): What is the difference between an interceptor and a filter?

Answer:

The interceptors are built around struts 2. It runs for all requests that qualify for a servlet filter front controller and can be customised to run extra interceptors for specific action execution. Interceptor methods can be configured to execute or not to execute using exclude and include methods.

Servlet specifications are used to create the filters. Executes on request and non-configurable method calls if the pattern matches.

Apache Spark Interview Questions & Answers

Ques. 9): Explain struts 2's XML-based validation.

Answer:

XML-based validation in Struts 2 adds more validation options, such as email validation, integer range validation, form validation field, expression validation, regex validation, needed validation, string length validation, and necessary string validation, among others. The XML file must be titled 'actionclass'-validation.xml in Struts 2.

Apache NiFi Interview Questions & Answers

Ques. 10): How Does Validation in Struts 2 Work?

Answer:

When the user clicks the submit button, Struts 2 will run the validate method, and if any of the if statements inside the method are true, Struts 2 will call the addFieldError method. Struts 2 will not proceed to invoke the execute method if any errors have been introduced. The Struts 2 framework, on the other hand, will return input as a result of calling the action.

When validation fails and Struts 2 returns input, the view file is redisplayed by the Struts 2 framework. Because we utilised Struts 2 form tags, the error messages will appear directly above the completed form.

These are the error messages we specified in the call to the addFieldError function. The addFieldError method takes two arguments. The first is the form field name to which the error applies and the second is the error message to display above that form field.

 

Ques. 11): What Types Of Validations Are Available In Xml Based Validation In Struts2?

Answer:

Following is the list of various types of field level and non-field level validation available in Struts2 −

  • date validator
  • double validator
  • email validator
  • expression validator
  • int validator
  • regex validator
  • required validator
  • requiredstring validator
  • stringlength validator
  • url validator

 

Ques. 12):  How Does Struts 2's Interceptor Work?

Answer:

The actual action will be performed by calling invocation.invoke() from the interceptor. So, depending on your needs, you can conduct some pre-processing and some post-processing.

The framework initiates the process by using the invoke method on the ActionInvocation object (). When invoke() is called, ActionInvocation consults its state and performs the next available interceptor. The invoke() method will cause the action to be executed once all of the configured interceptors have been invoked.

 

Ques. 13): What Is Value Stack?

Answer :

The value stack is a set of several objects which keeps the following objects in the provided order −

Temporary Objects − There are various temporary objects which are created during execution of a page. For example the current iteration value for a collection being looped over in a JSP tag.

The Model Object − If you are using model objects in your struts application, the current model object is placed before the action on the value stack.

The Action Object − This will be the current action object which is being executed.

Named Objects − These objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes.

 

Ques. 14): What Is The Difference Between Valuestack And OGNL?

Answer:

ValueStack is the storage space where Struts2 stores application data for processing client requests. The information is saved in ActionContext objects that use ThreadLocal to store values that are unique to each request thread.

OGNL (Object-Graph Navigation Language) is a sophisticated Expression Language for manipulating data on the ValueStack. Both interceptors and result pages can use OGNL to access data stored on ValueStack, as shown in the architectural diagram.

 

Ques. 15): What Is The Struts-default Package And How Does It Help?

Answer:

Struts-default is an abstract package that specifies all of the Struts2 interceptors as well as the most widely used interceptor stack. To prevent having to configure interceptors twice, it's best to extend this package while configuring our application package. This is provided to assist developers by making the work of configuring interceptor and result pages in our application a lot easier.

 

Ques. 16): What Is The Purpose Of @after Annotation?

Answer :

The @After annotation marks a action method that needs to be called after the main action method and the result was executed. Return value is ignored.

public class Employee extends ActionSupport{

   @After

   public void isValid() throws ValidationException {

      // validate model object, throw exception if failed

   }

   public String execute() {

      // perform secure action

      return SUCCESS;

   }

}

 

Ques. 17): What Is The Purpose Of @before Annotation?

Answer :

The @Before annotation marks a action method that needs to be called before the main action method and the result was executed. Return value is ignored.

public class Employee extends ActionSupport{

   @Before

   public void isAuthorized() throws AuthenticationException {

      // authorize request, throw exception if failed

   }

   public String execute() {

      // perform secure action

      return SUCCESS;

   }

}

 

Ques. 18): What Is The Difference Between Using An Action Interface And Using An Actionsupport Class For Our Action Classes, And Which Would You Prefer?

Answer:

To develop our action classes, we can use the Action interface. This interface only has one function, execute(), which we must implement. The main advantage of utilising this interface is that it includes some constants that can be used on result pages, such as SUCCESS, ERROR, NONE, INPUT, and LOGIN.

The ActionSupport class implements the Action interface by default, as well as interfaces for Validation and i18n support. Action, Validateable, ValidationAware, TextProvider, and LocaleProvider are all implemented by the ActionSupport class. To implement field level validation login in our action classes, we can override the validate() method of the ActionSupport class.

Depending on the requirements, we can use any of the approaches to create struts 2 action classes, my favorite is ActionSupport class because it helps in writing validation and i18n logic easily in action classes.

 

Ques. 19): How Do We Get Servlet Api Requests, Responses, Httpsessions, and Other Objects Into Action Classes?

Answer:

Servlet API components such as Request, Response, and Session are not directly accessible through Struts2 action classes. However, in some action classes, such as checking the HTTP method or adding cookies in the response, these accesses are required.

As a result, the Struts2 API exposes a number of *Aware interfaces through which we can access these objects. Struts2 API injects Servlet API components into action classes using dependency injection. SessionAware, ApplicationAware, ServletRequestAware, and ServletResponseAware are some of the most essential Aware interfaces.

 

Ques. 20): Is Struts2 Interceptors And Action Thread Safe?

Answer:

Because an object is instantiated for each request to process, Struts2 Action classes are thread safe.

Because Struts2 interceptors are singleton classes that launch a new thread to handle the request, they are not thread safe, and we must construct them carefully to avoid any shared data concerns.

 

 

 

 


January 04, 2022

Top 20 Apache Cassandra Interview Questions and Answers

  

                Apache recommends Cassandra as one of the most popular NoSQL distributed database management systems. Cassandra is an open-source database that is meant to store and manage enormous amounts of data without failure. Apache Cassandra is a Java database with flexible schemas that is highly scalable for Big Data models and was originally built by Facebook. There is no single point of failure with Apache Cassandra. Cassandra is a combination of column-oriented and key–value store databases, and it is one of the most popular NoSQL databases. The keyspace entity in Cassandra is the table or column family, which is the application's outermost container.

 Apache Camel Interview Questions and Answers

Ques. 1): What is the purpose of Cassandra and why should you utilise it?

Answer:

Cassandra was created with the goal of handling large data workloads across several nodes with no single point of failure. Cassandra's use is influenced by a number of things.

  • It's fault-tolerant and reliable.
  • Scalability from gigabytes to petabytes
  • It's a database with columns.
  • There are no singular points of failure.
  • There isn't a requirement for a separate caching layer.
  • Schema design that is adaptable
  • It has a flexible data storage system, simple data distribution, and quick write speeds.
  • The ACID (Atomicity, Consistency, Isolation, and Durability) qualities are supported.
  • Cloud and multi-data centre capabilities
  • Compression of data

 Apache Ant Interview Questions and Answers

Ques. 2): What are Cassandra's applications?

Answer:

When it comes to app development and data management, Cassandra has become the go-to solution for many businesses. Because of the ease with which an operator can work, even fresh start-ups choose it.

Cassandra is a fantastic application for collecting data from a variety of sources at a rapid rate. Cassandra could be used in an internet of things application. It might also be utilised in product and retail apps, as well as messaging, social media analytics, and even a recommendation engine.

 Apache Tomcat Interview Questions and Answers

Ques. 3): What are the advantages of utilising Cassandra?

Answer:

  • Apache Cassandra, unlike any other database, provides near real-time speed, making the work of Developers, Administrators, Data Analysts, and Software Engineers much easier.
  • Cassandra is built on a peer-to-peer architecture rather than a master–slave design, assuring no failure.
  • It also ensures incredible flexibility by allowing numerous nodes to be added to each Cassandra cluster in any data centre. In addition, any client can send a request to any server.
  • Cassandra supports extensible scalability and can be simply scaled up and down depending on the needs. This NoSQL application does not need to be restarted while scaling because it has a high throughput for read and write operations.
  • Cassandra is also known for its powerful data replication on nodes feature, which allows users to store data in numerous locations and recover data from a different location if one node fails. The amount of copies that users want to make can be set by them.
  • When used for large datasets, it performs admirably, making it the NoSQL DB of choice for most businesses.
  • Operates on a column-oriented structure, which speeds up and simplifies the slicing process. With a column-based data model, even data access and retrieval become more efficient.
  • Furthermore, Apache Cassandra features a schema-free/schema-optional data model, which eliminates the need to display all of the columns that your application requires.
  • Learn how Cassandra vs. MongoDB can help you advance your career.

 Apache Kafka Interview Questions and Answers

Ques. 4): In Cassandra, explain the idea of adjustable consistency.

Answer:

Cassandra's tunable consistency is a fantastic feature that makes it a popular database among developers, analysts, and big data architects. Consistency refers to all replicas having up-to-date and synced data rows. Cassandra's adjustable consistency allows users to choose the level of consistency that best suits their needs. It encourages two types of constancy: eventual and strong consistency.

The former ensures consistency when no new updates are made to a data item, i.e., all accesses eventually return the most recently modified value. Replica convergence is a term used to describe systems that achieve eventual consistency.

For strong consistency, Cassandra supports the following condition:

R + W > N where,

N – Number of replicas

W – Number of nodes that need to agree for a successful write

R – Number of nodes that need to agree for a successful read

 Apache Tapestry Interview Questions and Answers

Ques. 5): What is Cassandra's data storage method?

Answer:

Bytes are used to store all data.

Cassandra ensures that the bytes are encoded correctly when you specify validator.

The column is then ordered using a comparator depending on the encoding's specific ordering.

While composites are simply byte arrays with a specific encoding, each component holds a two-byte length, a byte encoded component, and a termination bit.

Apache Ambari interview Questions & Answers

Ques. 6): What is the definition of memtable?

Answer:

A memTable is a place where data is written and temporarily stored. After the data in the commit log has been completed, it is written to memtable.

In Cassandra, Memtable is a storage engine. Because each column category has its own MemTable, data in MemTable is classified into a key, and data is retrieved using the key. When the write memory is filled, the messages are automatically deleted.

 Apache Hive Interview Questions & Answers

Ques. 7): Explain the Bloom Filter concept.

Answer:

Bloom filter is an off-heap (off the Java heap to native memory) data structure associated with SSTable that checks whether there is any data accessible in the SSTable before conducting any I/O disc action.

 Apache Spark Interview Questions & Answers

Ques. 8): What are the functions of the shell commands "Capture" and "Consistency"?

Answer:

Cassandra has a number of Cqlsh shell commands. The command "Capture" saves the result of a command to a file, whereas the command "Consistency" shows the current consistency level or sets a new one.

 Apache NiFi Interview Questions & Answers

Ques. 9): What is the purpose of the read repair request?

Answer:

When the coordinator node sends requests, it checks in with the nodes to see if they have any outdated information. This data is transmitted to be read and repaired in the background before being replaced with the updated data. Read and repair requests are a way to maintain the data current while also ensuring that the requested row is consistent across all replicas.

 

Ques. 10): How does Cassandra write?

Answer:

Cassandra executes the write operation in two steps: first, it writes to a disc commit log, and then it commits to an in-memory structure called memtable. The write is complete after the two commits are successful. SSTables are used to store writes in the table structure (sorted string tables). Cassandra is more efficient when it comes to writing.

 

Ques. 11): What are the best Cassandra monitor tools?

Answer:

Despite the fact that Cassandra has built-in tolerance mechanisms, it still needs to be monitored for optimal outcomes. Cassandra utilises the following tools to keep track of its databases:

  • Solarwind server and application monitor
  • Instana
  • Instaclustr
  • AppDynamics
  • Dynatrace
  • Machine engine applications manager.

 

Ques. 12): What is Cassandra- CQL collections?

Answer:

Cassandra Multiple values can be stored in a single variable using CQL collections. CQL collections can be used in Cassandra in the following ways.

List: It is used when the order of the data needs to be maintained, and a value is to be stored multiple times (holds the list of unique elements)

SET: It is used for group of elements to store and returned in sorted orders (holds repeating elements)

MAP: It is a data type used to store a key-value pair of elements

 

Ques. 13): What is Super Column in Cassandra?

Answer:

Cassandra Super Column is a unique element consisting of similar collections of data. They are actually key–value pairs with values as columns. It is a sorted array of columns, and they follow a hierarchy when in action: keystore > column family > super column > column data structure in JSON.

Similar to the row keys, super column data entries contain no independent values but are used to collect other columns. It is interesting to note that super column keys appearing in different rows do not necessarily match and will not ever.

 

Ques. 14): Describe the CAP Theorem.

Answer:

With a strong necessity to scale systems when new resources are required, the CAP Theorem is critical to the scaling strategy's success. It's a good approach to deal with scaling in distributed systems. The Consistency, Availability, and Partition Tolerance (CAP) theorem asserts that customers can only have two of these three qualities in distributed systems like Cassandra.

It's necessary to sacrifice one of them. Consistency ensures that the client receives the most recent writing; availability ensures a sensible response in the shortest time possible; and partition tolerance ensures that the system continues to operate even if network partitions occur. AP and CP are the two alternatives available.

 

Ques. 15): What is the difference between Column and Super Column?

Answer:

Both elements work on the principle of tuples having name and value. However, the former’s value is a string, while the value of the latter is a map of columns with different data types.

Unlike Columns, Super Columns do not contain the third component of timestamp.

 

Ques. 16): What exactly is a Column Family?

Answer:

A column family, as the name implies, is a structure with an endless number of rows. A key–value pair is used to refer to these, with the key being the column name and the value being the column data. In Java, it's equivalent to a hashmap, while in Python, it's analogous to a dictionary. Remember that the columns in the rows are not confined to a specified list. Furthermore, the column family is extremely adaptable, with one row having 100 columns and the other simply having two.

 

Ques. 17): Define the management tools in Cassandra.

Answer:

DataStax OpsCenter: It is the Internet-based management and monitoring solution for Cassandra cluster and DataStax. It is free to download and includes an additional edition of OpsCenter.

SPM primarily administers Cassandra metrics and various OS and JVM metrics. Besides Cassandra, SPM also monitors Hadoop, Spark, Solr, Storm, ZooKeeper, and other Big Data platforms. The main features of SPM include correlation of events and metrics, distributed transaction tracing, creating real-time graphs with zooming, anomaly detection, and heartbeat alerting.

 

Ques. 18): In Cassandra, explain the distinctions between a node, a cluster, and a data centre.

Answer:

Cassandra is made up of several parts. A cluster is a collection of nodes that have comparable sorts of data organised together, whereas a node is a single machine running Cassandra. When serving consumers from different parts of the world, data centres are essential components. You can divide a cluster's nodes into various data centres.

 

Ques. 19): What is the purpose of the Bloom Filter in Cassandra?

Answer:

A bloom filter is a space-saving data structure for determining if an element belongs to a set. In other words, it's used to see if an SSTable contains data for a specific row. When executing a KEY LOOKUP in Cassandra, it is utilised to save IO.

 

Ques. 20): What exactly is SSTable? What makes it unique among relational tables?

Answer:

SSTable stands for 'Sorted String Table,' and it refers to a crucial Cassandra data file that supports regular written memtables. They exist for each Cassandra table and are kept on disc. Because of their immutability, SSTables do not allow the insertion or removal of data items once they have been written. Cassandra creates three different files for each SSTable: a partition index, a partition summary, and a bloom filter.

 

Top 20 Apache Camel Interview Questions and Answers

  

                    The Apache Camel software is a message-oriented middleware system that is free and open source. The mediation takes place according to the guidelines that have been established. It's used by a lot of companies for data processing and analysis. Camel can be thought of as a routing engine at a high level. Camel allows us to establish routing rules for messages to be sent from a specific source to a specified destination.

                    Camel has built-in support for a variety of protocols, making it simple to interconnect diverse systems. Camel can easily integrate two separate apps that function with ftp and jms. Camel handles all of the protocol and datatype conversions for us internally.

 Apache Spark Interview Questions & Answers

Ques. 1): What is Apache Camel, and how does it work?

Answer:

There are a variety of oscillate systems in an organisation. Some of them could be legacy systems, while others could be new. These systems frequently interact in imitation of one another and require integration. Relationships or integration are more difficult than system implementations because message formats may differ. One method to achieve this is to agree on a code that bridges these gaps. However, there will be a decrease in mitigation integration as a result of this. If there is a fiddle contemplating in a system tomorrow, the press on may have to be tainted, which is not pleasant. Instead of this narrowing to mitigation integration which causes tight coupling, we can espouse a supplementary descent to mediate the differences along surrounded by the systems.

 Apache Hive Interview Questions & Answers

Ques. 2): In Apache Camel, what are EIPs?

Answer:

EIP (Enterprise Integration Patterns) is the abbreviation for Enterprise Integration Patterns. In the form of a pattern, these are design patterns for the usage of enterprise application integration and message-oriented middleware. Apache Camel makes use of a number of EIPs. Here are a few:

Splitter Pattern: Split the data on the basis of some token and then process it.

Content Based Router: The Content-Based Router inspects the content of a message and routes it to another channel based on the content of the message. Using such a router enables the message producer to send messages to a single channel and leave it to the Content-Based Router to inspect messages and route them to the proper destination. This alleviates the sending application from this task and avoids coupling the message producer to specific destination channels.

Message Filter: A Message Filter is a special form of a Content-Based Router. It examines the message content and passes the message to another channel if the message content matches certain criteria. Otherwise, it discards the message.

Recipient List: A Content-Based Router allows us to route a message to the correct system based on message content. This process is transparent to the original sender in the sense that the originator simply sends the message to a channel, where the router picks it up and takes care of everything.

Wire Tap: Wire Tap allows you to route messages to a separate location while they are being forwarded to the ultimate destination.

 Apache Ambari interview Questions & Answers

Ques. 3): What are Apache Camel Components?

Answer:

In Apache Camel, a component is a factory or a group of Endpoint instances. When using Spring or Guice, we can explicitly configure Component instances and connect them to a Camel Context in an IoC container. URIs can be used to discover components automatically.

Apache Camel comes with a lot of pre-built components. Some key Camel components from the core module are listed below.

  • Bean
  • Direct
  • File
  • Log
  • SEDA
  • Timer

 Apache Tapestry Interview Questions and Answers

Ques. 4): What is an exchange in Apache camel?

Answer:

The message that will be routed through the Camel route is already in the Exchange. It's the holder of the message. Message Exchange Patterns are used by Apache Camel (MEP). Any type of communication can be stored in an Apache camel exchange. It accepts a variety of file types, including XML, JSON, and others.

 Apache Kafka Interview Questions and Answers

Ques. 5): What is an ESB? Have you deployed a camel for any ESB?

Answer:

Enterprise Service Bus (ESB) stands for Enterprise Service Bus. It is a tool that is used to help a severely pained application employing SOA concepts. When projects need integrating a number of Endpoints in front of Webservices, JMS, FTP, and other systems, an optimal unmodified ESB should be employed. JBoss Fuse ESB has been installed for Apache Camel Deployment.

 Apache Tomcat Interview Questions and Answers

Ques. 6): What is a row in the Apache camel?

Answer:

In the Exchange, the declaration to be routed via the Camel route is a gift. It is the possessor of the statement. Message Exchange Patterns are used by Apache Camel (MEP). Any nice of publication can be retained by Apache camel disputes. It supports a multitude of formats, including XML, JSON, and others.

 Apache Ant Interview Questions and Answers

Ques. 7): What are the apache camel endpoints?

Answer:

The Endpoint interface in Camel implements the Message Endpoint pattern. Endpoints are usually established by Components, and their URIs are used to refer to them in the DSL.

 Apache NiFi Interview Questions & Answers

Ques. 8): What is Apache JMeter?

Answer:

JMeter is an Apache project that is used as a load balancing tool to evaluate the performance of a variety of facilities, including the most sophisticated web applications.

JMeter can also be used as a unit-testing tool for JDBC database connections, FTP, Web services, JMS, HTTP, and TCP connections, as well as OS native processes. JMeter can also be configured as a monitor, though this is more of a monitoring tool than a believer control tool, and it can be used for active scrutiny as well. Jmeter also fosters integration when compared to Selenium, allowing it to control automation scripts in addition to performing or load testing.

 

Ques. 9): What is the Idempotent Consumer pattern in Apache Camel?

Answer:

We employ the Idempotent Consumer pattern in Apache Camel to filter out duplicate messages. Consider a case in which we must handle files without assistance while taking into account. Duplicates should be skipped if there are any. We may utilise Idempotent Consumer right within the component using Apache Camel, and it will skip files that have already been processed. The environment's idempotent=real choice will enable this feature. To do this, Apache Camel uses a statement-id, which is stored in the Idempotent Repository, to keep track of the consumed files. IdempotentRepository types are provided by Apache Camel.

 

Ques. 10): How does Apache Camel handle exceptions?

Answer:

The try> catch> block, the OnException> block, or the errorHandler> block can all be used to handle exceptions.

Any uncaught Exception thrown during the routing and processing of a message is handled by the errorHandler. On the other hand, when certain Exception types are thrown, onException is used to manage them.

 

Ques. 11): What is CamelContext, and how does it work?

Answer:

A single Camel routing rulebase is represented by the CamelContext. The CamelContext is comparable to the Spring ApplicationContext in that it is used in the same way. interface for the general public SuspendableService and RuntimeConfiguration are both extended by CamelContext. The context used to configure routes and policies to utilise during message exchanges between endpoints is represented by this interface.

 

Ques. 12): What is the best way to restart CamelContext?

Answer:

To govern the camel lifecycle, the camel context provides many methods such as start, stop, suspend, and resume. A service can be restarted using one of two techniques. Stopping the context and then starting it is one option. It's known as a cold restart, and it clears the internal state, cache, and other data to render all endpoints useless. Suspend and resume operations are another option. It saves all of your endpoints so you can use them again after you restart.

 

Ques. 13): What is an URI?

 Answer:

In camel, a URI is a naming system for referring to an endpoint. An URI informs Camel about the component being used, the context path, and the options that have been applied to it. The URI is made up of three parts:

  • Scheme
  • Context path
  • Options

Example of a file URI working as a consumer –

 from(“file:src/data?fileName=demo.txt&fileExist=Append”);

Here the scheme points to file, the context path is “src/data” and the options are “fileName and fileExist” are options that can be used with file component or file endpoint.

 

Ques. 14): In Apache Camel, what is the Idempotent Consumer pattern?

Answer:

We employ the Idempotent Consumer pattern in Apache Camel to filter out duplicate messages. Consider the case where we only need to process messages once. Duplicates should be skipped if there are any. We can utilise Idempotent Consumer directly within Apache Camel to bypass messages that have already been processed. The idempotent=true option is used to enable this feature. To do this, Apache Camel uses a message id, which is stored in the Idempotent Repository, to keep track of the consumed messages. IdempotentRepository is a kind of IdempotentRepository provided by Apache Camel.

 

Ques. 15): How to connect with Azure from Apache Camel?

Answer:

Yes. We can connect with azure services using Apache camel connector components.

Maven Dependency:

<dependency>

    <groupId>org.apache.camel</groupId>

    <artifactId>camel-azure-storage-queue</artifactId>

    <version>x.x.x</version>

  <!-- use the same version as your Camel core version -->

</dependency>

Code Example:

from(”azure-storage-queue://storageAccount/messageQueue?accessKey=yourAccessKey”).to(”file://queuedirectory”);

 

Ques. 16): What is a Message in Apache Camel ?

Answer:

Message implements the Message pattern and represents an inbound or outbound message as part of an Exchange.It contains the data being transferred using Routes- It consists of the following fields-

  • Unique Identifier
  • Headers
  • Body
  • Fault Flag

 

Ques. 17): What is the relationship between Apache Camel and ActiveMQ?

Answer:

Apache Camel is embedded in the ActiveMQ broker using the ActiveMQ component. It allows you a lot of versatility when it comes to extending the message broker. Additionally, the ActiveMQ component eliminates the serialisation and network costs associated with connecting to ActiveMQ remotely.

This component is built on the JMS component and allows users to send and consume messages over the JMS Queue.

 

Ques. 18): How do I disable JMX in Apache Camel?

Answer: 

The JMX instrumentation agent is enabled in Camel by default. To disable the JMX instrumentation agent, set the following property in the Java VM system property,

Dorg.apache.camel.jmx.disabled=true

Another way of disabling is by adding the JMX agent element inside the camel context element in the Spring configuration,

<camelContext id=”camel” xmlns=”https://camel.apache.org/schema/spring”>

<jmxAgent id=”agent” disabled=”true”/>

  

</camelContext>

 

Ques. 19): What Jars Do I Need?

Answer :

Camel is designed to be small lightweight and extremely modular so that you only pay for what you use. The core of camel, camel-core.jar is small and has minimal dependencies.

On Java 6 camel-core.jar only depends on

commons-management.jar (for Camel 2.8 or older)

commons-logging.jar (for Camel 2.6 or older)

slf4j-api.jar (from Camel 2.7 onwards)

On Java 5 camel-core.jar depends also on activation.jar and a JAXB2 implementation which typically involves jaxb-api.jar, jaxb-impl.jar and a StAX API which may be stax-api.jar and *woodstox.jar

 

Ques. 20): What Is The Difference Between A Producer And A Consumer Endpoint?

Answer:

A camel route is similar to a data channel in that it transports data. At either end of the channel, there are two endpoints: producer and consumer.

The route's beginning point is called a consumer endpoint. Writing a camel consumer endpoint is the first step in defining a camel route.

A producer endpoint appears at the end of the route (but not always). The data that is passed through the route is consumed by it.