Wiki source code of Drop Files

Last modified by Eva Torken on 2023/05/09 11:38

Show last authors
1 {{container}}{{container layoutStyle="columns"}}(((
2
3 In the last microlearning, we discussed how we can retrieve files **from** a local directory.
4 In this microlearning we will learn the opposite, how to deliver files **to** a local directory
5
6 Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]].
7
8 == 1. Prerequisites ==
9
10 * Basic knowledge of the eMagiz platform
11
12 == 2. Key concepts ==
13
14 This microlearning centers around dropping files to a local directory via eMagiz.
15 By dropping we mean: Writing the contents of the message to a local directory to be stored as a file
16 By local directory we mean: A directory that is directly accessible within the network where the eMagiz process is running
17
18 Key considerations when dropping files are:
19
20 * In which directory should we place the file
21 * Has eMagiz the appropriate rights to read from the directory where the messages are to be retrieved from
22 * If a file with the same name already exists what do we do
23 * How to name the file that you are writing to the directory
24
25
26
27 == 3. Drop Files ==
28
29 One of the easiest connectivity methods to implement within eMagiz is sending files to a local directory.
30 With this method, eMagiz will write data to the local directory when data arrives on an exit queue for processing.
31 There are four key considerations you should take into account when picking up files:
32
33 * In which directory should we place the file
34 * Has eMagiz the appropriate rights to read from the directory where the messages are to be retrieved from
35 * If a file with the same name already exists what do we do
36 * How to name the file that you are writing to the directory
37
38 === 3.1 Determine the directory ===
39
40 The key aspect of delivering a message is knowing where to deliver a message to. The same applies to delivering messages as files on a local directory.
41 The external party with whom you are connecting should be able to provide you with the directory where the data should be delivered to.
42
43 The best practice is to work with a property as the directory can change between environments.
44 To ensure that a wrong directory is created by eMagiz the best practice is to **not** let eMagiz auto-create the directory.
45 The basic configuration of the file outbound channel adapter should therefore look as follows:
46
47 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-outbound-channel-adapter.png]]
48
49 === 3.2 Appropriate Rights ===
50
51 To send files to a local directory eMagiz needs to have the appropriate rights to access the directory in question.
52 If the directory in which the files are located is part of a structure of other directories you need to ensure that eMagiz
53 has sufficient rights on all directories above the directory to which you are writing data.
54
55 If this is not the case you will not be able to send data to a local directory via eMagiz.
56
57 === 3.3 What to do when a file already exists ===
58
59 In eMagiz, you can configure what eMagiz should do in case the file you are trying to write to the directory already exists.
60 The default pattern is to replace the original file with the new file ensuring that the newest information is available.
61
62 However, if there are reasons not to replace the original file with the new file considering one of the options below:
63
64 * Append. With this option, you append the new data to the original file
65 * Fail. eMagiz will throw an error when the file already exists
66 * Ignore. eMagiz will silently drop the message when the file already exists
67
68 To choose a specific mode you have to navigate to the Advanced tab and access the Mode drop-down menu.
69
70 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-mode-options.png]]
71
72 === 3.4 Name the file ===
73
74 If you do not name the file eMagiz will use the message ID with the suffix .msg. In general, you do not want that so you should specify how the file should be named.
75
76 There are two methods to do so. The first method is more static and the second one is more dynamic.
77
78 ==== 3.4.1 Format File Name Generator ====
79
80 The first option is the format file name generator. This is a support object in eMagiz
81
82 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-format-file-name-generator.png]]
83
84 This component has several tokens available that can be replaced with values. However, in some cases, some of these tokens are not filled in at all.
85
86 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-format-file-name-generator-tokens.png]]
87
88 Therefore we see that this component is mainly used to combine some static value with one of these tokens. An example of such a construction is shown below.
89
90 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-format-file-name-example.png]]
91
92 This way you control that the message has a certain extension and starts always with the same value. The only dynamic part in this example is the time that is added to the file name
93
94 ==== 3.4.2 File Name Header ====
95
96 Another option that gives you more flexibility is to define the file name header.
97 By adding a standard header enricher component to your exit you can define your file name as follows:
98
99 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-drop-files--drop-file-file-name-header-example.png]]
100
101 Do note that the naming of the header matters. Only when you name your header file_name this solution will work. Otherwise, eMagiz will revert to the default so pay attention!
102
103 As you can see from the example we will now dynamically create the file name based on two input variables for which the values can change.
104 Whichever method you choose to create the file name does not matter as long as you have thought about it.
105 Most important thing is that you choose an option to keep control over what is happening.
106
107 == 4. Key takeaways ==
108
109 * Key considerations when dropping files are:
110 * In which directory should we place the file
111 * Has eMagiz the appropriate rights to read from the directory where the messages are to be retrieved from
112 * If a file with the same name already exists what do we do
113 * How to name the file that you are writing to the directory
114
115 == 5. Suggested Additional Readings ==
116
117 If you are interested in this topic and want more information on it please read the help text provided by eMagiz.
118
119 )))((({{toc/}}))){{/container}}{{/container}}