SMB Connectivity

Last modified by Danniar Firdausy on 2024/09/18 20:40

In many scenarios, accessing or managing files directly through a local directory isn't feasible, or external requirements might necessitate file placement in different locations. Typically, file transfers are handled via FTP or SFTP protocols, but another option available is Server Message Block (SMB) connectivity. In this microlearning, we will explore how SMB connectivity works within eMagiz, examining how it facilitates file transfers between local and remote systems.

Should you have any questions, please get in touch with academy@emagiz.com.

1. Prerequisites

  • Basic knowledge of the eMagiz platform
  • Novice course on File-based connectivity

2. Key concepts

This microlearning is about SMB (connectivity).

  • By SMB connectivity, we mean: Making sure that eMagiz can communicate with the SMB protocol to exchange file-based data.

3. SMB Connectivity

In some cases, there is no communication possible with a local file directory. Or there is a requirement from the external party to place the files somewhere else. Mainly the somewhere else is either an FTP or an SFTP. However, there is a third communication protocol that can be used for file transfer. In this microlearning we will take a look at Server Message Block (SMB) connectivity within eMagiz.

  • SMB (Server Message Block) is a network protocol for transmitting files between computers over Transmission Control Protocol/Internet Protocol (TCP/IP) connections.
  • In an SMB transaction, the end user's computer is typically called the localhost. The second computer involved in SMB is a remote host, which is usually a server.
  • Servers must be set up to run SMB services, and the client must have SMB software installed to access these services.
  • eMagiz provides several components to set up the SMB connection

So, where the file pickup component searches on the local host for the correct directory, the idea of the SMB setup is that the directory with whom to communicate exists on a remote host. The local host and the remote host can talk to each other via the SMB protocol. That is, in a nutshell, the difference between setting up an SMB connection and communicating with local directories.

Note that the auto create directory setting on all SMB components only works for a "one-level" directory (i.e. /directory) and not for a "multi-level" directory (i.e. /directory/sub). To ensure this "multi-level" directory is created by eMagiz you need to take a look at this microlearning

eMagiz provides only one support object to connect to an SMB:

  • SMB session factory

intermediate-file-based-connectivity-smb-connectivity-smb-support-object.png

3.1 Configuration in eMagiz

To configure the connection between eMagiz and the SMB, we need two (or three) components. This depends on whether we want to read, write or do both while communicating with the SMB. If we're going to do both, we need both of the functional components. In all other scenarios, you only need one of the functional components. The functional components that you might need are called:

  • SMB inbound Channel adapter
  • SMB outbound Channel adapter

On top of that, you need the following support object.

  • SMB session factory

In this microlearning, we will use the SMB inbound channel adapter combined with the SMB session factory to illustrate the configuration. Please note that any other combination works similarly. To configure the connection with the SMB, we first navigate to the Create phase of eMagiz. Here we open the flow we want to edit. In this example, that will be an entry flow as we want to retrieve (read) data from the SMB.

When you have opened the flow, you need to enter "Start Editing" mode. After you have done so, we first add the SMB session factory support object to our flow.

intermediate-file-based-connectivity-smb-connectivity-smb-session-factory-empty.png

Here, we need to define the following:

  • Host
  • Port
  • Username
  • Password
  • Share and directory

The value for the share and directory field is the main folder for your file share. If the main folder is the exchange folder, then within the SMB inbound channel adapter, a / is needed as remote directory.

intermediate-file-based-connectivity-smb-connectivity-smb-session-factory-filled-in.png

In the advanced tab there are only two settings to change. The minimum and maximum SMB protocol version. By default, these are set to 2.02 and 3.1.1 respectively to allow a wide range of save protocol version. However, if you want to only allow the best performing version, the minimum 3.0.2 is advised. If you aim for the best secured connection version 3.1.1 has the most functionality in this area. The best practise on this is set the minimum version as high as possible to mimize risks.

Now that we have configured the support object,we can add the SMB inbound channel adapter to the flow.

intermediate-file-based-connectivity-smb-connectivity-smb-inbound-channel-adapter-empty.png

In this component, we need to define the remote directory where the original files are located. We need to specify the local directory used to store the files before they are processed temporarily. Furthermore, we need to link the support object we have just created and define a poller. For that last one, the best practice is the use of a cron trigger.

intermediate-file-based-connectivity-smb-connectivity-smb-inbound-channel-adapter-filled-in.png

Apart from these configurations, you could also add a filter, just as we learned in the Crash Course Messaging on file-based connectivity. Finishing things off, we should consider the delete behavior we will use. Based on the filter and the business requirements, whether to delete and when to delete could differ. So please consider all your options in that regard. In case there are multiple readers from the folder and/or there are legal requirements to store source files for a certain time period, you should not use the delete remote files option. However, not deleting files read files can cause overloading the machine if no alternative delete policies is in place.

3.2 SMB Gateway

The SMB Gateway is an additional component that can be used to interact with your SMB share. It allows the use of a set of pre-configured commands to perform actions such as deleting files. Compared to the outbound channel adapter replies are send back to eMagiz. These reply messages depend on the selected command. Every command option is explained in detail within the helptext. An example configuration to send files is shown below.

intermediate-file-based-connectivity-smb-connectivity-smb-outbound-gateway-filled-in.png

Please note that for some commands an SpEL expression is required to respresent a path. This setting can be found in the advanced settings. An example for the mget command could be myfilesdirectory/ to get only files from this directory.

All available options are:

  • List files
  • List file names
  • Retrieve file
  • Retrieve multiple files
  • Remove file(s)
  • Move/rename file
  • Send file
  • Send mulitple files

This concludes our microlearning, in which we learned how to set up the connectivity with an SMB.

4. Key takeaways

  • Server Message Block (SMB) is a network protocol used for sharing files between computers over TCP/IP connections. It allows a client to access files on a remote server as if they were on the local machine.
  • In an SMB transaction, the end user's computer is typically called the localhost. The second computer involved in SMB is a remote host, which is usually a server.
  • Servers must be set up to run SMB services, and the client must have SMB software installed to access these services.
  • To use SMB with eMagiz, you'll need the SMB Gateway component (that offers pre-configured commands for managing files), the SMB session factory and either an SMB inbound or outbound channel adapter (depending on whether you're reading from or writing to the SMB share).

5. Suggested Additional Readings

If you are interested in this topic and want more information, please read the release notes provided by eMagiz. Furthermore, check out these links: